Hey, i was practicing member intialisers.. But I am being accused by the compiler for not declaring my class :p . I was actually accesing my class from another file. Can you tell me, where i am wrong.
1 2 3 4 5 6 7 8 9 10 11 12
//the main.cpp
#include <iostream>
#include "tanmay.h"
usingnamespace std;
int main()
{
tanmay myobject(23, 45)// a constructor with paramerters;
so.print();
return 0;
}
___
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#ifndef TANMAY_H
#define TANMAY_H
class tanmay
{
public:
tanmay(int a, int b);
void print();
private:
int ma;
constint asd;
};
#endif // TANMAY_H
__
1 2 3 4 5 6 7 8 9 10 11 12
//the tanmay.cpp
#include "tanmay.h"
usingnamespace std;
tanmay::tanmay(int a, int b)
:int ma(a), asd(b)
// asd is a cionstant // member insiat6lieser syntax
{
//ctor
}
void tanmay::print(){
cout<<"normal is "<<ma<<" constan is "<<asd;
}