Dear all,

I have written a program in c++ to pass arrays of objects(belonging to the same class) to a member function. It works fine in VC++ but gives an error as "Undefined structure class name". My program is a larger one. So i am giving a similar code below. Pls help me. Your replies are highly appreciated. Thanking you.

#include <iostream.h>
#include <conio.h>

class test
{
int k;
public:
void fun(test t[])
{
cout<<"Test program....";
}
};

void main()
{
test t;
test r[2];
t.fun(r);
getch();
}


Regds,
Beuls

It works fine in VC++ but gives an error as "Undefined structure class name".

How can it work and give you an error at the same time?

See the changed code...and before asking why I changed some lines...do a search of this forum or google...

#include <iostream>
using namespace std;
class test
{
int k;
public:
void fun(test t[],int size)
{
cout<<"Test program....";
}
};

int main()
{
test t;
test r[2];
t.fun(r,2);
return 0;
}

Thanks for your reply. The code works well in VC++ whereas it gives the error "Undefined structure class name" in Turbo C++.

Beuls

How can it work and give you an error at the same time?

See the changed code...and before asking why I changed some lines...do a search of this forum or google...

#include <iostream>
using namespace std;
class test
{
int k;
public:
void fun(test t[],int size)
{
cout<<"Test program....";
}
};

int main()
{
test t;
test r[2];
t.fun(r,2);
return 0;
}

don't use turbo c again

Thank you for ur reply. But i am working as a lecturer and have to teach Turbo C for my students.

Beuls

But i am working as a lecturer and have to teach Turbo C for my students.
Beuls

I am sure you don't have a reason(atleast a valid one)to teach C/C++ using that crappy compiler.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.