c++ visual c++ compiler - job interview

middlepath

Recruit
hi all,

i am a computer science, msis graduate since 2000 and trying to move to programming from systems administration with a job interview and exam this thursday.......

i have installed dev c++, turbo c++, borland c++, and now visual c++

my program is : the first program gives an iostream error
cube.cpp
#include <iostream.h>
#include "cube.h"
Cube::Cube(){}
Cube::~Cube(){}
void Cube::setSide(double s){
Side = s <= 0 ? 1 : s;
}double Cube::getSide(){
return Side;
}
double Cube::Area(){ return 6 * Side * Side;
}
double Cube::Volume(){ return Side * Side * Side;
}void Cube::properties(){ cout << "Characteristics of this cube";
cout << "\nSide = " << getSide();
cout << "\nArea = " << Area();
cout << "\nVolume = " << Volume() << "\n\n";
}

cube.h

#ifndef CUBE_H#
define CUBE_H
class Cube{
public: Cube();
~Cube();
void setSide(double s);
double getSide();
double Area();
double Volume();
void Properties();
private:
double Side;
};
#endif

exo.cpp
#include "cube.h"
void main(){ Cube cube;
cube.setSide(-12.55);
cube.Properties();
Cube de;
de.setSide(28.15);
de.Properties();}

any help with this will be highly appreciated.......
 
Methods of Cube class needs to be written in cube.h file itself

correct starting of cube.h file would be like this

#ifndef CUBE_H
define CUBE_H
#endif
class Cube{
...
};
 
just a tip, since you have just 24 hours til the interview in which time you have to become a programming pro, i would suggest reading one of those "learn C++ in 24hrs" kind of books :D
 
The latest compilers give an error when you add .h to the c++ standard library headers. i.e., iostream.h

it should be #include <iostream> instead of #include <iostream.h>
 
booo said:
The latest compilers give an error when you add .h to the c++ standard library headers. i.e., iostream.h

it should be #include <iostream> instead of #include <iostream.h>

actually you can use that but than you have to use the std name space too. When you are excluding .h compiler include it for your convenience.
 
Back
Top