[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

reference to pointer

Posted on 1997-04-06
6
Medium Priority
?
198 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
Industry Leaders: 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

650 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