49,757 Topics

Member Avatar for
Member Avatar for sfurlow72

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] …

Member Avatar for L7Sqr
0
178
Member Avatar for nivek10

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 …

Member Avatar for nivek10
0
325
Member Avatar for triumphost

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 …

Member Avatar for triumphost
0
757
Member Avatar for james6754

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 …

Member Avatar for thines01
0
102
Member Avatar for ThomsonGB

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 …

Member Avatar for ThomsonGB
0
1K
Member Avatar for kuramahiei

[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 …

Member Avatar for kuramahiei
0
166
Member Avatar for triumphost

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 …

Member Avatar for mike_2000_17
0
102
Member Avatar for gabriellogan

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, …

0
105
Member Avatar for Chuckleluck

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 …

Member Avatar for mrnutty
0
181
Member Avatar for Zvjezdan23

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. =/ …

0
85
Member Avatar for prasenjit_das

Hi ALL, Which c++ compiler is best creating graphics related project.please suggest me. thanks in advance

Member Avatar for DeanMSands3
0
2K
Member Avatar for Rubinder singh

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 …

Member Avatar for CityThrille
0
505
Member Avatar for minxminx

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 …

Member Avatar for Labdabeta
0
577
Member Avatar for jtbens01

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 …

Member Avatar for mrnutty
0
130
Member Avatar for jonnyboy12

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 …

Member Avatar for Ancient Dragon
0
217
Member Avatar for Susmita_Sikder

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

Member Avatar for Ancient Dragon
0
170
Member Avatar for utkarshsahu

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= …

Member Avatar for utkarshsahu
0
183
Member Avatar for Bennys

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 = …

0
41
Member Avatar for ayershuja

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 …

Member Avatar for jigglymig
0
115
Member Avatar for jigglymig

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 …

Member Avatar for jigglymig
0
238
Member Avatar for shopnobhumi

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 …

Member Avatar for kavita_gunaji
0
809
Member Avatar for Quicxic

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 …

Member Avatar for Quicxic
0
199
Member Avatar for aakanaa

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

0
43
Member Avatar for rfrapp

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 …

Member Avatar for rfrapp
0
254
Member Avatar for triumphost

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 …

Member Avatar for mike_2000_17
0
313
Member Avatar for sfurlow72

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 …

Member Avatar for sfurlow72
0
135
Member Avatar for nik2012

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. …

Member Avatar for nik2012
0
1K
Member Avatar for exdx

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 …

0
42
Member Avatar for Fess

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

0
142
Member Avatar for tom12

[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 …

Member Avatar for tom12
0
86

The End.