Hello there,
I have been working on a little piece of code that is part of some work for my C++ course in university. Now I am not going to lie, I suck at C++ regardless of how hard I try to learn it.
The following code had some errors in which I had to locate and fix:
#include <iostream>
using std::cout; using std::endl;
void create(void);
class Count
{
public:
Count(int=1, int=1);
void print() const {cout << day << " " << num << endl;}
private:
int day;
int num;
};
Count::Count(int d, int c)
{
day = d;
num = c;
}
int main()
{
Count firstObj;
Count secondObj(2,3);
secondObj.print();
return 0;
}
The only thing I don't understand is why void create(void); is necessary for the program to run. Any clarification would be appreciated.
What do you mean it is necessary to run? Are you getting a compile error when removing it? I don't see any function call or implementation for create() anywhere in your program.
I think has to do with the MS compiler and the type of project you are compiling as, but I am not a windows programmer. You might get more help by moving this subject to the Windows programming forum.
I commented out that line and compiled the project in Visual Studio 2008 with no trouble. The function prototype has no purpose in the code you provided. Are you sure that there is nothing else in the project? You might want to try creating a new project to see if you still get the error.