I use Turbo C++ and am experiencing an unexpected error in my code, please help.. I am trying to pass an array of objects to a member function. An error : Undefined structure test , pops on the line where i define my print function
#include<iostream.h>
#include<conio.h>
class test
{
int t;
public:
void print(test T[])
{
cout<<"This Test\n";
}
};
void main()
{
clrscr();
test T1,T2[5];
T1.print(T2);
getch();
}
I have to use the outdated version of the Turbo C++ compiler at school so the syntax of the code might be different than the new compilers.
Define your function as void print(test *T)
.
Turbo C++ is broken in the regard of parameters of type test[]
being equivalent to test*
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.