I am new to C++ and a Computer Science Student and I a seem to be missing something because as I look into my text book and try to run their example to understand it, it continues to come up with errors. This is an example in the text book which is a problem because it isn't working right now.
Just in care I am on a Windows 8.1 system using the wxDev-C++ compiler to process my work because this is what my college has us using.
#include<iostream>
usingnamespace std;
void displayValue(int num);
int main()
{
int x; //I added this to hold screen from closing.
cout << "I'm passing 5 to displayValue. \n"
displayValue(5);
cout << "Back to main \n";
cin >> x; // I added this to hold screen from closing.
return 0
}
void displayValue(int num)
{
cout << "The value is" << num << endl;
}
//The rest of the code is as is in the book minus comments.
The errors are:
D:\Virgilio\Documents\Coding\C++\Practice Projects\FunctionPractice_2.cpp In function 'int main()'::
5 D:\Virgilio\Documents\Coding\C++\Practice Projects\FunctionPractice_2.cpp:12 expected ';' before 'displayValue'
1 D:\Virgilio\Documents\Coding\C++\Practice Projects\FunctionPractice_2.cpp:18 expected ';' before '}' token
HELP!!! What is wrong because now I don't understand what this book is trying to teach me in class.
Thank you so much, I will correct that. I was so busy trying to make sure I didn't miss anything and go figure a semicolon takes me out. I spent an hour reading and rereading the lesson trying to figure out what was wrong. DUH! I guess these will be the growing pains of learning. Thanks again.