View Single Post
Old 09-12-2015, 12:23 AM   #13
llyair
Wiki Staff
Retired StaffFFR Veteran
 
llyair's Avatar
 
Join Date: Jun 2014
Posts: 307
Default Re: [University - C++ Programming] Filling an Array with RNG & Display Contents

Quote:
Originally Posted by FoJaR View Post
also i'm not sure what your teacher's policy on
Code:
using namespace std
is but generally it is not the best idea
Agreed about the using namespace std, but I guess code style can be fixed after you have something running and understand it.

Quote:
Originally Posted by sickufully View Post
I'm confused by the fact that Display has been initialised before Main and then it's then called twice, but once within Main and once again outside of it. Can someone explain this to me? More along the lines of what does the first Display call do?
This page explains different uses of function names:
http://www.cprogramming.com/declare_vs_define.html

It also has a really simplified example, but it's similar to what you have with Display() showing up three times. Just copying the code here for convenience:
Code:
int func();

int main()
{
    int x = func();
}

int func()
{
    return 2;
}
See the section with this code, it'll explain the reason for func() showing up 3x.
llyair is offline   Reply With Quote