pointer adn reference

October 21, 2010 at 00:00:38
Specs: Windows XP
i am learning pointer and references but my this program giving me error.


#include "stdafx.h"
#include<iostream>
using namespace std;
struct bigone
{
int serno;
char text[1000];

}
bo={123,"this is a big structure"};
void valfunc(bigone v1);
void ptrfunc(const bigone *pl);//call by pointer
void reffunc(const bigone &rl); //call by refernece

int _tmain(int argc, _TCHAR* argv[])
{
valfunc(bo);
ptrfunc(&bo);
reffunc(bo);
return 0;
}

//functiond efination

void valfunc(bigone v1)
{
cout<<'\n'<<v1.serno;
cout<<'\n'<<v1.text;
}

//call by pointer
void ptrfunc( bigone *p1)
{
cout<<'\n'<<pl-->serno;
cout<<'\n'<<pl-->text;

}
//pass by reference

void refunc(const bigone &rl)
{
cout<<'\n'<<rl.serno;
cout<<'\n'<<rl.text;

}

it should excess text and serno htroght pointer but not working.

can anybody help me!


See More: pointer adn reference

Report •

#1
October 21, 2010 at 07:16:18
1) Include any error messages when asking about said error messages.
2) It's ->, not --> (one dash)
3) The header is p1 (pee one), but the function body uses pl (pee el)

How To Ask Questions The Smart Way


Report •

#2
October 21, 2010 at 18:49:28
yes i got my mistake but now i got again errors.. now my program is:

#include "stdafx.h"
#include<iostream>
using namespace std;
struct bigone
{
int serno;
char text[1000];

}
bo={123,"this is a big structure"};
void valfunc(bigone v1);
void ptrfunc(const bigone *pl);//call by pointer
void reffunc(const bigone &rl); //call by refernece

int _tmain(int argc, _TCHAR* argv[])
{
valfunc(bo);
ptrfunc(&bo);
reffunc(bo);
return 0;
}

//functiond efination

void valfunc(bigone v1)
{
cout<<'\n'<<v1.serno;
cout<<'\n'<<v1.text;
}

//call by pointer
void ptrfunc( bigone *pl)
{
cout<<'\n'<<pl-->serno;
cout<<'\n'<<pl-->text;

}
//pass by reference

void refunc(const bigone &rl)
{
cout<<'\n'<<rl.serno;
cout<<'\n'<<rl.text;

}

Errors are :
error C2065: 'serno' : undeclared identifier
error C2065: 'text' : undeclared identifier

now it s still not working..


Report •

#3
October 22, 2010 at 05:33:24
See point 2 in the previous reply.

How To Ask Questions The Smart Way


Report •
Related Solutions


Ask Question