?
Solved

reference to pointer

Posted on 1997-04-06
6
Medium Priority
?
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 210 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

777 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