I am writing a program to store in a class a particular temp. I'm not very far along and am new to classes so I don't really understand this syntax error. The program is probably not very good but I'm just getting started and can't figure this out. The error is commented out. Thanks.
Your problem is that you did not create a temp object none the less one called temp in your main function.
Also you shouldn't be allowed to or even try and name a object the same as the objects type. Ex Dont do int int or temp temp or string string.
Your main function should look like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14
int main ()
{
temp tmp; //Creating a temp object called tmp
char type;
cout << "Enter the type of temperature: ";
cin >> type;
if (type == 'f' || type =='F')
{
tmp.setFahrenheit (); //The error was because you were trying
//to create a temp object and call a function at same time
//This would be the same as string.find(); or some function
}
}
I am getting hit with an error saying that the function is inaccessible. I think I may have tried that before because I remember getting a similar error. My book isn't being very helpful nor the searches on the web.
Most likely this is because you have not declared any visibility on the class functions, which implies they are private (only visible within the class).