No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
34 Posted Topics
Hello I am currently making a program for a database which includes an SSN. The user can input the ssn but I want it in xxx-xx-xxxx and to make sure the user ddoes this have the user input 3 numbers then 2 numbers then 4 numbers in seperate cin statements: … | |
It is my understanding that in C++ objects of derived classes invoke the derived class' constructor but before the body is executed the base class' constructor is invoked and takes effect and then the derived class' constructor's body is executed. If this knowledge is correct, then what happens if the … | |
I have been trying to make a program that uses derived classes but have run into a problem. I get the error type: " error C2440: '=' : cannot convert from 'const char [16]' to 'char' " when I try and intialize a char array of 255 to "Name Unknown" … | |
I was testing which constructors are called in when a derived and then base class objects are created. My program couted 0 if it was the base class and 1 if it was the base class. I ran it and it returned 01 for the derived class and 0 for … | |
My textbook says "Constructors cannot be virtual. (Think about it: constructors are called to create new objects. However, if you don't know what type of object you're trying to create, how do you know which constructor to invoke?)" but I am not sure what it means by this. Is it … | |
Hello I have been trying to understand virtual functions for a while and when I made a program to demonstrate the use of virtual functions it didn't and someone gave me this piece of code that would demonstrate the proper way to utilize a virtual function: [code=c++] #include"derived.h" #include<iostream> using … | |
I have recently learned about virtual functions and it is to my understanding that they are a keyword that goes in front of the return type when defining a function. They go in a base class, and make it so that if a member function of the base class is … | |
Hello, I posted a program about converting furlongs to kilometers and other conversions concerning those 2 main units. These errors kept popping up: error C2027: use of undefined type 'Kilometer' see declaration of 'Kilometer' error C2228: left of '.getkilometers' must have class/struct/union error C2027: use of undefined type 'Kilometer' see … | |
Hello, I have been working a week on this program with this stupid bug that gives tons of errors. I have narrowed them down to 4 errors and 2 warnings but I have no idea how to fix the 4 errors. The program is supposed to have two user defined … | |
I just have one question, when you have a class that is defined: [code=C++] class box{ public: int *value; box() { value=new int; *value=0; }; box(box &c) {*value=*c.value;}; }; [/code] If in the main you said class box b(a); it would work as expected. But I don't understand how that … | |
So when two objects are declared say class shoe shoe1 and class shoe shoe_copy and then shoe1's variables are set, if the line of code: shoe_copy=shoe1; what would that be doing? After all what is the real data structure of the objects of class shoe? | |
If an explicit copy constructor is defined that makes a complex copy, does: [code=C++] int main() { class shoe shoe1; class shoe shoe_copy(shoe1); } [/code] And [code=C++] int main() { class shoe shoe1; class shoe shoe_copy; shoe_copy=shoe1; } [/code] Basically I'm asking if the assignment operator accesses the complex copy … | |
When a parameter in a function definition (for say class distance) is abc(distance a) and in the main you call this function and pass distance b, what is the relationship thereafter between distance a and b? Do there adresses become equal-if so what implications does that have in the program? | |
Hello I was researching the copy constructor and found this exampleo a website: [code=C++] #include <iostream> class Array { public: int size; int* data; Array(int size) : size(size), data(new int[size]) {} ~Array() { delete[] data; } }; int main() { Array first(20); first.data[0] = 25; { Array copy = first; … | |
Hi lately i have been studying the malloc and calloc functions for dynamically allocating memory. I thought the form was: [code=C] (data_type*) malloc(data_size); [/code] But then I stumbled onto this code snippet on a tutorial site: [code=c] #include <cstdlib> void *malloc( size_t size ); [/code] Why is the data type … | |
When a pointer is deleted, is the memory it is pointing to only returned to the heap or is it also nulled too? Thx | |
Say I have a class (say number) and declare a private variable (say int num) and have a public member function(say int getnum() ) that retrieves the private variable. When I in the main() without initializing the private variable int num (of course after declaring the class variable say test) … | |
Hi I have to do an assignment for a course that includes that I use new stream insertion and stream extraction techniques. On the lecture notes it briefly mentioned cin.get() and getline but not in a very descriptive way. Could anyone please summarize the use of get() when inputting more … | |
Hello I was making a program called englishweight and it has three main components englishweight.h which is a class declaration, englishweight_def.cpp which defines the public member fucntions, and EW_driver which uses the class to calculate what to do with the englishweight and preforms very basic operations. My program works WITHOUT … | |
I am getting errors that I have never seen before in a program that uses class englishweight with float number and float eng_weight to output number*englishweight and other things in the EW_driver.cpp. Here is what my build log looks like: ------ Build started: Project: assignment_2, Configuration: Debug Win32 ------1>Compiling...1>EW_Driver.cpp1>Linking...1>EW_Driver.obj : … | |
OK I'm a beginner at C++ so don't mock me for this question, so when I declare a pointer ptr (int *ptr; ) and then define ptr as 5 by saying *ptr=5; what adress is ptr pointing at-a temporary variable? Thank you-just curious. | |
Hi, I was making a pogram to demostrate static variables and I don't know why my compiler (VS 2005) is giving me these crazy errors that my book im using said I shouldn't be getting. Here is my program, please help: header: [code=C++] class number{ private: static int num; public: … | |
I was writing a simple class to test my understanding of class and the first class program had a number -int num private- that was modified by the user by void definenum(num) and retrieved with int getnum(). It functioned as I expected-i would define it as 4 and it would … | |
Hello, I am very new to programming and want to know if anyone knows of a good internship or course that they recommend, near San Diego California preferably. Also any seminars or useful websites that would broaden my IT/programming knowledge. | |
![]() | Re: You should make the rules less restricitve andjust include the objective: "to determine how much property damage that the drunks in the town will do while they are wandering about the streets interacting with the tea-totallers and the police" ![]() |
I've been studying enums lately and decided to make a program with it to test the enum syntax and my first one worked. It was: [code=c++] #include<iostream> using namespace std; int main() { enum daysinweek{ monday=0, tuesday=1, }; enum daysinweek enumerator=monday; cout<<enumerator<<endl; system("pause"); return 0; } [/code] It worked perfectly, … | |
Re: .....We dont do your homework for you, explain the program that your suposed to make THOROUGHLY and then give your thoughts and problems with the specific assignment rather than demanding a program you describe in a 1 word blunder as if we're slaves. Stop spazzing out and realize that there … | |
Re: Post your code and also, did you do like Vern did and by initializing cost set it equal to 0 or anything when you declare it? | |
I am doing an online course and for one of the chapters (in [U]Practical C++ Programming[/U] by Steve Oualline) it had a bitmapped graphics section-only 4 pages long. The chapter is about bit operations and includes a section about hexadecimals. I understoodit until I got to this passage in bitmapped … | |
I tried to make a simple function that takes an array parameter and outputs it and it keeps giving me th error: \function test.cpp(12) : error C2664: 'func' : cannot convert parameter 1 from 'int' to 'int []' 1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast … | |
My dad has a Windows Vista computer and suddenly today the internet didn't work. So we restarted it a few times and it still didn't work. We tried to ping google and it worked and in task manager it said that the wireless internet and hard line were both working. … | |
My dad has a Windows Vista computer and suddenly today the internet didn't work. So we restarted it a few times and it still didn't work. We tried to ping google and it worked and in task manager it said that the wireless internet and hard line were both working. … | |
I know this is probably a very stupid question, but I can't make the user input a string.I thought I could use cin...here is my code: [code=C++] #include<iostream> //#include<cstdlib> //#include<cstdio> #include<cstring> using namespace std; int main() { int x=0; string thing[10]; cin>>thing; //x=atoi(thing.c_str()); //cout<<x; system("pause"); return 0; } [/code] I … | |
I'm trying to figure out how to use the atoi function I have wrote and understand this so far: #include<iostream> #include<cstdlib> #include<cstring> using namespace std; int main() { int x; string str="34"; x=atoi(str); cout<<x; system("pause"); return 0; } And Then I get error reports about a freakin const char?! HELP! |
The End.