[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[rhn-users] g++ error



Hear is a small program which give the following error when compiling under
redhat 9.0 but with redhat 7.0 it work fine when  using g++ or gcc
*************************************************************
#include <iostream>
#include<fstream>
class Customer
{
private:
 char mobileNo[11];
 char name [25];
 char dateofBirth [9];
 char billingAddress [51];
 char city [25];
 char phoneNo [11];
 float amountOutstanding;
public:
 void print()
 {
         cout << endl << "Mobile Phone number: " ;
                cout << mobileNo << endl;
  cout << "Name: ";
  cout << name << endl;
  cout << "Date of Birth: ";
  cout << dateofBirth << endl;
  cout << "Customer's billing address: ";
  cout << billingAddress << endl;
  cout << "City: ";
  cout << city << endl;
  cout << "Resident Phone number: ";
  cout << phoneNo << endl;
  cout << "Amount due: ";
  cout << amountOutstanding << endl;
 }
 void get()
 {
  cout << "Mobile phone number: ";
  cin>> mobileNo;
  cin.ignore();
  cout << endl << "Name: ";
  cin.getline(name,25);
  cout << endl << "Date of Birth: ";
  cin >> dateofBirth;
  cin.ignore();
  cout << endl << "Customer's billing address: ";
  cin.getline(billingAddress,51);
  cout << endl << "City: ";
  cin.getline(city,25);
  cout << endl << "Residence phone number: ";
  cin >> phoneNo;
  cout << endl << "Amount due: ";
  cin >> amountOutstanding;
 }
};
int main ()
{
 Customer object;
 fstream file;
 char reply = 'Y';
 file.open("customer.dat",ios::out|ios::app);
 while(reply == 'Y' || reply == 'Y')
 {
  
  cout << "Enter Customer details " <endl;
  object.get();
  file.write((char *)&object,sizeof(object));
  cout << "Do you wish to continue ?[y/n]";
  cin >> reply;
 }
 file.close();
 file.open ("customer.dat",ios::in);
 file.read((char *)&object, sizeof(object));
 while(file)
 {
  object.print();
  file.read((char *)&object, sizeof(object));
 }
 file.close();
 return 0;
}   
*****************************************************
test1.cc: In member function `void Customer::print()':
test1.cc:16: `cout' undeclared (first use this function)
test1.cc:16: (Each undeclared identifier is reported only once for each
   function it appears in.)
test1.cc:16: `endl' undeclared (first use this function)
test1.cc: In member function `void Customer::get()':
test1.cc:34: `cin' undeclared (first use this function)
test1.cc: In function `int main()':
test1.cc:54: `fstream' undeclared (first use this function)
test1.cc:54: parse error before `;' token
test1.cc:56: `file' undeclared (first use this function)
test1.cc:56: `ios' undeclared (first use this function)
test1.cc:56: parse error before `::' token
/usr/include/c++/3.2.2/iostream:51:   also declared as `std::ostream std::cout'
   here
/usr/include/c++/3.2.2/ostream:257:   also declared as `
   std::basic_ostream<_CharT, _Traits>& std::endl(std::basic_ostream<_CharT,
   _Traits>&)' here
/usr/include/c++/3.2.2/iostream:51:   also declared as `std::ostream std::cout'
   here
/usr/include/c++/3.2.2/iostream:50:   also declared as `std::istream std::cin'
   here
test1.cc:67: parse error before `::' token
 
************************************************************************when i incude using namespace std;
 
************************************************************************it give that error
test1.cc: In function `int main()':
test1.cc:61: no match for `std::basic_ostream<char, std::char_traits<char> >& <
   <unknown type>' operator
************************************************************************an another small one
 
#include <iostream.h>
int main()
{
 cout << "hello";
 return 0;
}
 
************************************************************************it give the following error
 
In file included from /usr/include/c++/3.2.2/backward/iostream.h:31,
                 from hello.cc:1:
/usr/include/c++/3.2.2/backward/backward_warning.h:32:2: warning: #warning This
file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples
include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning
use -Wno-deprecated.
But when compiling this one
#include <iostream.>
int main()
{
 cout << "hello";
 return 0;
}
the following error is given
hello.cc: In function `int main()':
hello.cc:4: `cout' undeclared (first use this function)
hello.cc:4: (Each undeclared identifier is reported only once for each function
   it appears in.)
********************************************************
i have update the following package
glibc-2.3.2-27.9.i386.rpm
glibc-2.3.2-27.9.i686.rpm
glibc-2.3.2-27.9.src.rpm
glibc-common-2.3.2-27.9.i386.rpm
glibc-debug-2.3.2-27.9.i386.rpm
glibc-devel-2.3.2-27.9.i386.rpm
glibc-profile-2.3.2-27.9.i386.rpm
glibc-utils-2.3.2-27.9.i386.rpm
nptl-devel-2.3.2-27.9.i686.rpm
 
with out any result
 
any one can help me

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]