Solved

reference to pointer

Posted on 1997-04-06
6
193 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

776 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