Problem with members initialisers

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"
using namespace 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;
        const int asd;
};

#endif // TANMAY_H 

__

1
2
3
4
5
6
7
8
9
10
11
12
//the tanmay.cpp
#include "tanmay.h"
using namespace 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;
}
cpp line 5, remove "int " from that line.
Okay, that was some small glitch.
But it didnt solve the problem either..
where is the object "so", line 9 in main.cpp
Topic archived. No new replies allowed.