Solved

reference to pointer

Posted on 1997-04-06
6
192 Views
Last Modified: 2012-05-04
I just have the following declaration:
struct stack
{  char type;
   char *ptr;
   stack *next;
}
Later, when I declare a new function:
void push(char& typ, char *nptr)
{  stack* newnode = new stack;
   newnode->type  = typ;
   newnode->*ptr  = *nptr;
   newnode->next  = point;
   point = newnode;
// point has been assigned as NULL at start
}

When I compile, it said that "ptr is an undefined symbol".
What is the problem?

Or, can I use array to implement it instead of pointer, but how can I reference to the char. string in the function?

Thanks a lot.
0
Comment
Question by:snap
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:white wolf
ID: 1162605
What do you mean by "Guard"???  
What's "Guard"?  You didn't mention
it in your question???

0
 

Expert Comment

by:joesynaptics
ID: 1162606

It's true that I don't see 'guard' in your code anywhere,
but I do notice two things about your code...

One is that newnode->*ptr = nptr; is (my guess) wrong,
you don't want the * there.  If your code really has a
* there, that might be your problem in some indirect
way.

(The other is, and there's nothing technically wrong with
your code here, but, there really isn't any point in
passing typ by reference.  Sorry to nitpick.  This has
nothing to do w/your warning.)


0
 

Author Comment

by:snap
ID: 1162607
Edited text of question
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:snap
ID: 1162608
Edited text of question
0
 

Author Comment

by:snap
ID: 1162609
Edited text of question
0
 

Accepted Solution

by:
joesynaptics earned 70 total points
ID: 1162610

Ahhh.

Replace

newnode->*ptr = *nptr;

with

newnode->ptr = nptr;

If I understand you correctly, that should do it.


0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now