NOT RUNNING

#include<iostream.h>
#include<conio.h>

class numbers
{
private:
int a,b;

public:
void readnumbers();
void add();
};

void numbers::readnumbers()
{
cout<<"Enter the value of a: ";
cin>>a;

cout<<"Enter the value of b: ";
cin>>b;
}

void numbers:: add()
{
int c=a+b;
cout<<"Addition: "<<c;
}

void main()
{
clrscr();
numbers num;
num.readnumbers();
num.add();
getch();
}
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<iostream>           // iostream, not iostream.h
//#include<conio.h>        
using namespace std;         // ahem - not everyone's gonna like this

class numbers
{
   private:
   int a,b;

public:
   void readnumbers();
   void add();
};

void numbers::readnumbers()
{
   cout<<"Enter the value of a: ";
   cin>>a;

   cout<<"Enter the value of b: ";
   cin>>b;
}

void numbers::add()
{
   int c=a+b;
   cout<<"Addition: "<<c;
}

int main()                   // int main, not void main
{
// clrscr();
   numbers num;
   num.readnumbers();
   num.add();
// getch();                  
} 


Enter the value of a: 1
Enter the value of b: 2
Addition: 3
WHEN I REPLACE <iostream>
AND REPLACED using namespace std; INSTEAD <conio.h> then following errors are coming
1)UNABLE TO OPEN INCLUDE FILE 'IOSTREAM' THIS ERROR IS COMING
2)DECLARATION SYNTAX ERROR
3)UNDEFINED SYMBOL 'COUT
4)UNDEFINED SYMBOL 'CIN
@p01ajanikar I'm guessing you are using Turbo C++ 3,0, is that the case?
I understand that some education courses still use it - but bear in mind that it is well over 20 years old and bears no resemblance to modern standardised C++.
Yes, I'm using Turbo 3.2 for educational purpose, so what should I need for practice?
If you have a choice, and are not constrained by college rules or something, use one of code::blocks or Visual Studio Express.

More details on the tutorial page:
http://www.cplusplus.com/doc/tutorial/introduction/
WORKING PERFECT!!!!
THANKS...
Topic archived. No new replies allowed.