error C2228: left of '.b' must have class/struct/union type

Dear experts,

I am getting the error mentioned in the Title.

#include<iostream.h>

struct ABC
{
ABC()
{

}

int a;

};


template<class interfacetype>
struct DEF
{
DEF(interfacetype val) : stoutput(val)
{

}


interfacetype& stoutput;

int b;
};


DEF<class interfacetype> obj(ABC);


void func()
{

obj.b = 20;
}


void main()
{

func();
}

Can anyone help me to ged rid of this error message.

Regards,
Ravi




1) The header is called iostream, not iostream.h
2a) "class interfacetype" is wrong when declaring obj. You need to provide an actual type (ABC).
2b) The constructor takes an object of type ABC, so you need to provide one.
2c) In this form, it will count as a function declaration. Use = syntax instead.
3) the correct main prototype is int main().
Last edited on
Topic archived. No new replies allowed.