howdy,
this is my first experience with class objects. i created this class however i have some questions about why it works.
by pure luck i got the "GetName()" and "SetName()" functions to work by adding the pointer ref's - something i saw in a book - but i dont know what they (the pointers) do.
in the "Label()" function i can name objects but i dont think i am creating objects. how would i create multiple objects of this class from user input.
this is my first try with classes so any other suggestions would be appriciated.
Code:
#include <iostream.h>
#include <math.h>
using namespace std;
class SBeam
{
public:
char SBeamName;
SBeam();
~SBeam();
char* GetName();
char* SetName();
char Label();
private:
int Depth();
char ItsName[6];
int SbeamDepth;
int depth;
};
SBeam::SBeam()
{
}
SBeam::~SBeam()
{
}
char* SBeam::SetName()
{
cout<<"Enter Beam Name: \n";
cin.getline(ItsName, 6);
Depth();
return ItsName;
}
char* SBeam::GetName()
{
return ItsName;
}
int SBeam::Depth()
{
cout<<"Enter Beam Depth: ";
cin>>depth;
return depth;
}
char SBeam::Label()
{
cout<<"The Beam Label: "<<GetName()<<", "<<depth<<"!\n";
return 0;
}
int main()
{
SBeam B1;
B1.SetName();
B1.Label();
return 0;
}
Thanks
M.R.