Connecting Tech Pros Worldwide Forums | Help | Site Map

output not showing up

Newbie
 
Join Date: Jan 2007
Posts: 1
#1: Jan 5 '07
hi every one
i have a problem n c++
I wrote a prgram when i use ctrl-f9 to execute it the blak window comes and immediately disappears;when i use system("pause");or console.ReadLine();
i have an error"parameter names are used only with a function body"
i dont know what to do with it
(this is my program:
#include<iostream.h>

class smallobj //declare a class
{private:
int somedata; //class data
public:
void setdata(int d) //member function to set data
{somedata=d;}
void showdata() //mamber function to display data
{cout<<"data is"<<somedata<<endl;}
system("pause");
};
int main(){
smallobj s1,s2; //define two objects of class smalloj
s1.setdata(1066);//call member function to set data
s2.setdata(1776);
s1.showdata(); //callmember function to display data
s2.showdata();
return 0;
}


///thank u for help)
Expert
 
Join Date: Nov 2006
Location: UK
Posts: 1,320
#2: Jan 5 '07

re: output not showing up


put the pause() inside the showdata() function, e.g.
Expand|Select|Wrap|Line Numbers
  1. void showdata() //mamber function to display data
  2. {cout<<"data is"<<somedata<<endl;//}  ** removed
  3. system("pause");
  4. }  // ** added
  5.  
Reply