49,757 Topics
| |
What's the difference between having a const function and declaring const after the function? For example, if I had a class Myclass with some private data members and I set up a public function called int getMyValue(), what would the difference be between declaring that function as: [CODE]const int getMyValue();[/CODE] … | |
class class1 { //variable declaration }; class class2 { public: int func(void *msg); // others func... }; int class2::func(void *msg) { class1 *pointer = (class1 *)msg; //others declaration. } I would like to ask reagrding on this line of code : class1 *pointer = (class1 *)msg; the class declaring a … | |
When do I really need to use Delete in Destructors? if I do Point P = new Point(); I've been told every time I use new, it stays in memory even when out of scope and that I should use delete to remove it.. so do i need to do … | |
I have put my code in to separate classes instead of having it just inside one class. Here is my constructor, I have also included my file which defines the class (#include "Matrix.h") [CODE] Matrix::Matrix(int* m,int* n)//constructor takes two ints { M = (*m); N = (*n); this->ptr = new … | |
I am trying to parse main(argc, argv[]); and i need to look at individual characters with in the strings pointed to by *argv[]. I though of a string as an array of chars. This builds fine but causes an error in execution. So what is a simple and straight forward … | |
[CODE] void command() { int CourseDistance, StartTime, FinishTime; char cmdChar = ' '; do { cout << "Command? : "; cin.get(cmdChar); switch (cmdChar) { case 'd': case 'D': cout << "Enter New Course Distance (NM): "; cin >> CourseDistance; break; case 's': case 'S': cout << "Enter New Race Start … | |
I did not know WHERE to ask this as there is no "General" section on the site this site that I know of. Lets say I found code online but it's under the GPL 3 License.. I read it but it doesn't say that I cannot translate it from Pascal … | |
I want to modify this Radix sort C++ to work with strings only. I want to sort words not numbers. I don't know what to change or where to change it. Any suggestions? [CODE] // CS 9F // March 3, 2012 // Include files #include <iostream> // used for cin, … | |
Hello, Suppose I have a chess game. I make a nice class to handle an entire player's pieces: [CODE]class c_ChessTeam { private: // all pieces derive from class c_ChessPiece c_Rook Rook[2]; c_King King; c_Queen Queen; c_Bishop Bishop[2]; c_Knight Knight[2]; c_Pawn Pawn[8]; public: . . . };[/CODE] But what if I'm … | |
Hi everyone! =) Since my teacher can't help me out or doesn't respond when his hours say he's in his online office, I need some help. I am coding Tetris; and I have to say I'm doing a decent job so far. I just need help with constant movement. =/ … | |
Hi ALL, Which c++ compiler is best creating graphics related project.please suggest me. thanks in advance | |
I am using windows 7 ultimate 32-bit edition, But when I try to run any dos screen like command prompt, c++ compiler etc. They are not going to full screen mode, Please tell me how to run my c++ compiler or any dos screen in full screen mode ……in windows … | |
This is a code which sorts arrays. I use clock_t to determine the processing time for my code. However, it always stacks with the time taken from before. It looks like it's just adding the results. [code] int main(int argc, char *argv[]) {unsigned long n;//size of array -- long for … | |
| Hi all, I'm having trouble will inheritance in c++. I am using a BaseNode class and deriving other node classes that can except different types of data. The problem I am running into is I can't find a way to make a decent copy function that can make an exact … |
Hello all. I am working with managed c++ ,cli. I am working on a large project and cannot afford to make any mistakes. In cli from what i have seen usually when i construct classes i use this ^ character to do so, like this [CODE] //header file public ref … | |
hallo everybody, i am doing program in dev c++ 4.9.9.2,but problem is that when i run a program under one project which contains more than one programs then it gives a warning.." project is not compiled".where i am wrong..please give me solution. thank you in advance | |
I wanted to write a program to check if string entered is a palidrome. I wrote a program but i get errors while compiling. Can anyone help me identify errors in the program. [CODE] #include<iostream> #include<string> int main(){ string input;bool flag=false; cout<<"Enter String: "; cin>>input; cout<<"You Entered "<<input; int length= … | |
I have a program for class where I have to read a file of with names and numbers into a class of objects and dynamically allocate it. Header file [code]#include <string> #include<cstring> using namespace std; class Movie { private: string movies; float rating; double profit; public: Movie() { movies = … | |
using circular link list by using class Class Employee { Eid integer ; Ename string; Esalary real ; Edesignation string ; } how we can do following operation: Create a link list Insert a node after a specific node with a given Eid Insert a node before a specific node … | |
I am trying to make the heapSort function I wrote work with the heapRebuild I was given. If someone could please tell me what exactly I am doing wrong or help point me in the right direction. [CODE]void Heap::heapRebuild(int root) { // if the root is not a leaf and … | |
Hi i have just started my c++ class and really having hard time with that.i was assigned to draw a graph which should look like dis : ***** ***** ***** ***** ***** This is what i am trying but getting only this result : ***** * * * * Please … | |
Hello, I have a problem with a header I'm trying to make. In Main.cpp, I have this function to store the combinations of the elements of vector S: [CODE=c++]template <class T> vector<vector<T> > combinations(vector<T> S, ll k) { vector<vector<ll> > combs = ncombinations(S.size(), k); vector<vector<T> > setcomb(combs.size(), vector<T>()); for(unsigned int … | |
Hi, i am new to C++. recently i have a project that require to create an array of queue. However, i don't have an idea how to create this. Can i create an array of queue by doing queue<int> q[2]? Any explanation will help, thank you very much | |
Hello, I need to demonstrate the binary search using recursion, and I've run into a little problem. In my example, if "key" was 1, 2, 3, or 6, then it would return true. Anything else would give me an error. Why is that? Here's my code: [CODE] // binary search.cpp … | |
Am I wrong that the answer is 2?? Teacher refuses and says that it's 3 because the compiler spits out 3 for ans.. but if I do it manually with pen an paper or with the cout<<v2%v1++, it spits out 2 which is what I get on paper.. [CODE] #include … | |
When trying to run, the compiler tells me that I cannot access the private data members. I'm just curious as to what's causing this error. Here's my class declaration: [CODE] #include <iostream> #include <string> using namespace std; #ifndef SALARY_H #define SALARY_H class Salary { public: const int getDepNum(); const int … | |
Hello. I am learning C++, and I am a little stuck. Right now, I'm working on pointers. The problem I'm working on requires sorting an array of structures, using pointers instead of array indices, using a selection sort. My code is not working, and I can't quite figure out why. … | |
hey, i am a beginner and we got stuck with my algorithm homework assignment on radixsort. question is followed: struct listnode *radixsort(struct listnode *data, int a, int k) which takes a linked list of unsigned long integers, each less than a^k, and sorts them by k rounds of bucketsort with … | |
Me and my team are working with arduino devices for a project and we need a way to talk and respond from arduino to visual studios. any coding out there to work on this because i can not seem to find any myself | |
[CODE]void RemoveVowels(char *str) { int i = 0; int lenght = strlen(str); for(i=0;i < lenght-1;i++) { if (str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u' || str[i]=='A' || str[i]=='E' || str[i]=='I' || str[i]=='O' || str[i]=='U') { str[i]=' '; } } } [/CODE] Hey guys having trouble trying to remove … |
The End.