Declaring Functions

Started by
3 comments, last by krazkidd2000 21 years, 6 months ago
I''m designing my first console app, so I made it small. All it does is ask for a student''s grades, and tells you what they have in the class. Anyhoo, I don''t know how to define a function! Can anybody help? Thanks, dudes.
Advertisement
NEVERMIND! I LOOKED IN MY C++ FOR DUMMIES BOOK AND GOT IT TO WORK! WATCH OUT NINTENDO! HERE I COME!
Didnt you buy the book for your class?? Weren''t you paying attention to your teacher?? Your gonna be in trouble when you get to defining class structures if you dont shape up anyways here is a simple void function called printName...

//Start code
void printName(); //Declare the function

int main()
{
printName(); //Call the function

return 0;
}

void printName() //Write the function
{
cout << "Your name is Shitfor Brains" << endl;
}


you can also write the whole function(without declaring it) BEFORE the main() and it will work too.
Assuming the function will not be updated that often, you would want to declare the function first then stick the definition at the end of your source code or stuff it into it''s own .cxx file. That way you don''t have to scroll through a bunch of source code to get to what you are actually working on. I''d rather have a bunch of individual files and more one line #include statements than one million line text file, but maybe that''s just me, I don''t know.

This topic is closed to new replies.

Advertisement