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
Solved

reference to pointer

Posted on 1997-04-06
6
194 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
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 viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

839 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