Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Anyone know C+ and have an hour to spare?
New Posts  All Forums:Forum Nav:

Anyone know C+ and have an hour to spare? - Page 2

post #11 of 13
Thread Starter 
Quote:
Originally Posted by joemaniaci;12910238 
Yeh, I was about to say, it couldn't be equal to both 0 and 6.

Yah, thanks.

Can u look at this one? I'm reading up on Prototypes right now. Kinda lost.

Write a statement that declares a prototype for a function printArray , which has two parameters. The first parameter is an array of ints and the second is an int , the number of elements in the array. The function does not return a value.
post #12 of 13
Prototypes are the exact same thing but without the function body, and usually go in a header file.

So,

void printArray(int x[], int y);

...in c++ you don't need to include anything in the brackets, but wherever you declared the array, it needs to be instantiated.
Edited by joemaniaci - 3/28/11 at 9:21pm
I Love Cheese
(13 items)
 
  
CPUMotherboardGraphicsRAM
2600k @ 3.4 Asus P8P67 Basic XFX 5970 2 gig Black Edition 2x 4 gig DDR 1600 G-Skill 
Hard DriveOSMonitorPower
2x500 gig WD Vista Ultimate 64-bit Dual 25" Hannspree LCD CM 750 Watt 
CaseMouse
Rosewill THOR Logitech Trackball 
  hide details  
Reply
I Love Cheese
(13 items)
 
  
CPUMotherboardGraphicsRAM
2600k @ 3.4 Asus P8P67 Basic XFX 5970 2 gig Black Edition 2x 4 gig DDR 1600 G-Skill 
Hard DriveOSMonitorPower
2x500 gig WD Vista Ultimate 64-bit Dual 25" Hannspree LCD CM 750 Watt 
CaseMouse
Rosewill THOR Logitech Trackball 
  hide details  
Reply
post #13 of 13
Quote:
Originally Posted by joemaniaci View Post
Prototypes are the exact same thing but without the function body, and usually go in a header file.

So,

void printArray(int x[], int y);

...in c++ you don't need to include anything in the brackets, but wherever you declared the array, it needs to be instantiated.
pretty much what he said..."setting up" your cpp program takes time to learn, including all the directives...when you perform a c++ program...you will have a header file(something.h) and a c++ file(something.cpp). The below code is missing all the directives, but you can look at those later and understand them on your own.
Code:
//.cpp file
void printArray(int x[], int y){      <---------function definition


}

Code:
//.h file


class something{


      public:
  
              void printArray(int x[], int y);   <----function prototype


};

Edited by surfbumb - 3/28/11 at 11:13pm
Black Silence
(15 items)
 
  
CPUMotherboardRAMHard Drive
i5 3570k @ 4.5 GHz Asus P8Z77-M Pro Kingston HyperX Genesis 8 GB - 1600 MHz Seagate Barracuda 250 GB 
Optical DriveCoolingOSMonitor
Samsung WriteMaster Noctua NH-D14 Windows 10 ASUS VS24AH-P 
KeyboardPowerCaseMouse
Logitech Navigator Enermax Infiniti 650W Fractal R3 Black Pearl Razer Death Adder 
Mouse PadAudio
SteelSeries QcK Mass Altec Lansing FX4021 
  hide details  
Reply
Black Silence
(15 items)
 
  
CPUMotherboardRAMHard Drive
i5 3570k @ 4.5 GHz Asus P8Z77-M Pro Kingston HyperX Genesis 8 GB - 1600 MHz Seagate Barracuda 250 GB 
Optical DriveCoolingOSMonitor
Samsung WriteMaster Noctua NH-D14 Windows 10 ASUS VS24AH-P 
KeyboardPowerCaseMouse
Logitech Navigator Enermax Infiniti 650W Fractal R3 Black Pearl Razer Death Adder 
Mouse PadAudio
SteelSeries QcK Mass Altec Lansing FX4021 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Anyone know C+ and have an hour to spare?