Statement questions

What is a function, class, and etc?
Are functions statements?

1
2
3
4
5
6
7
8
  //Why is this possible
void blah(/*blah blah blah*/)
{
//blah blah blah
};// This semicolon

//and also
cout << "blah" << endl;;;;;;;;;;;;;;;;
Last edited on
functions are a GROUP OF STATEMENTS
Your cout statement is printing a hard coded text output that by coincidence is the name of your functionish example. Its the same as cout << "text unrelated to anything at all";

now, this is more interesting:
string blah()
{
return "how exciting!";
}


cout << blah(); //note the difference, no quotes, () function call syntax, and the function returns a value that has meaning to cout (a string of text, here).

its not a bad thing to think of function in terms of the math … y = f(x); //look familiar? variable = foo(parameters); … right? But a group of statements works too. Different ways to look at it.
Last edited on
While this does not directly answer your question, most of these links should answer your questions. These are the sites and YouTube Playlists that have helped me a TON while learning C++. I recommend bookmarking them and checking them out.


This Site for Tutorials, Help, and general information:
- http://www.cplusplus.com/>

C++ Tutorials:
- https://www.youtube.com/playlist?list=PL318A5EB91569E29A
- https://www.learncpp.com/>
- https://www.youtube.com/playlist?list=PL68244A805BD16617

C++ Examples:
- https://www.youtube.com/playlist?list=PL6xSOsbVA1eaxY06L5ZZJfDZSohwO6AKY

C++ Datastructures: (More advanced)
- https://www.youtube.com/playlist?list=PL6xSOsbVA1eZdXRQCwydeva90oZGLgR1v

Things to Avoid in C++:
- http://www.gidnetwork.com/b-56.html

Hope this helps! =)
Topic archived. No new replies allowed.