Hello someone said that I should check this forum out for help to my c++
problems.
I will admit at this point I may have really ran myself into the ground
with this code that I am writing, but I'm hoping for a little help from
you guys.
I have a class that needs use of a bread-first search of a quareney tree.
In this class I have a nested class that should be the implementation of a
tree that contains two nested classes of its own. Those two classes are a
Position representation of cartestian coordinate with accessors and
modifiers and comparison methods. The other inner class is a treenode
class. This class holds several things, first of all a * to a vector of
TreeNode * that represent children nodes, A Position as its Payload, A *
to the parent TreeNode, and * pointer to a Maze object no mentioned above.
So, my problem is that as I iterate over my children vector I would like
to access the payload members accessors of the current treenode in the
vector. Except I get this instead:
error: request for member `payload' in `
*(&p1)->__gnu_cxx::__n ormal_iterator< _Iterator, _Container>::op erator->
[with _Iterator = cs371p::prog::r obowars4::Robot ::Tree::TreeNod e**,
_Container =
std::vector<cs3 71p::prog::robo wars4::Robot::T ree::TreeNode*,
std::allocator< cs371p::prog::r obowars4::Robot ::Tree::TreeNod e*> >]()',
which
is of non-class type `cs371p::prog:: robowars4::Robo t::Tree::TreeNo de*'
The line of code looks like this:
vector< TreeNode *>::iterator p1;
for(p1 = children->begin();p1 != children->end();++p1)
This LINE RIGHT HERE->>>> p1->payload->getX();
Please, lemme know what you think any feed back is appreciated
--Chad 3 2089
Chad E. Dollins wrote: Hello someone said that I should check this forum out for help to my c++ problems.
I will admit at this point I may have really ran myself into the ground with this code that I am writing, but I'm hoping for a little help from you guys.
I have a class that needs use of a bread-first search of a quareney tree. In this class I have a nested class that should be the implementation of a tree that contains two nested classes of its own. Those two classes are a Position representation of cartestian coordinate with accessors and modifiers and comparison methods. The other inner class is a treenode class. This class holds several things, first of all a * to a vector of TreeNode * that represent children nodes, A Position as its Payload, A * to the parent TreeNode, and * pointer to a Maze object no mentioned above.
So, my problem is that as I iterate over my children vector I would like to access the payload members accessors of the current treenode in the vector. Except I get this instead: error: request for member `payload' in ` *(&p1)->__gnu_cxx::__n ormal_iterator< _Iterator, _Container>::op erator-> [with _Iterator = cs371p::prog::r obowars4::Robot ::Tree::TreeNod e**, _Container = std::vector<cs3 71p::prog::robo wars4::Robot::T ree::TreeNode*, std::allocator< cs371p::prog::r obowars4::Robot ::Tree::TreeNod e*> >]()', which is of non-class type `cs371p::prog:: robowars4::Robo t::Tree::TreeNo de*'
The line of code looks like this: vector< TreeNode *>::iterator p1; for(p1 = children->begin();p1 != children->end();++p1) This LINE RIGHT HERE->>>> p1->payload->getX();
Try
(*p1)->payload->getX();
Keep in mind: p1 is an iterator; *p1 is the element of the vector it
designates; this element is itself a pointer pointing to some element that
presumably has a member "payload". Please, lemme know what you think any feed back is appreciated
--Chad
Best
Kai-Uwe Bux
Ok same question as before accept this temp trying to call member function
with from an index of the vector<TreeNode * > * myMoves
error ridden code:
myMoves[x]->makeChildren() ;
On Mon, 7 Nov 2005, Kai-Uwe Bux wrote: Chad E. Dollins wrote:
Hello someone said that I should check this forum out for help to my c++ problems.
I will admit at this point I may have really ran myself into the ground with this code that I am writing, but I'm hoping for a little help from you guys.
I have a class that needs use of a bread-first search of a quareney tree. In this class I have a nested class that should be the implementation of a tree that contains two nested classes of its own. Those two classes are a Position representation of cartestian coordinate with accessors and modifiers and comparison methods. The other inner class is a treenode class. This class holds several things, first of all a * to a vector of TreeNode * that represent children nodes, A Position as its Payload, A * to the parent TreeNode, and * pointer to a Maze object no mentioned above.
So, my problem is that as I iterate over my children vector I would like to access the payload members accessors of the current treenode in the vector. Except I get this instead: error: request for member `payload' in ` *(&p1)->__gnu_cxx::__n ormal_iterator< _Iterator, _Container>::op erator-> [with _Iterator = cs371p::prog::r obowars4::Robot ::Tree::TreeNod e**, _Container = std::vector<cs3 71p::prog::robo wars4::Robot::T ree::TreeNode*, std::allocator< cs371p::prog::r obowars4::Robot ::Tree::TreeNod e*> >]()', which is of non-class type `cs371p::prog:: robowars4::Robo t::Tree::TreeNo de*'
The line of code looks like this: vector< TreeNode *>::iterator p1; for(p1 = children->begin();p1 != children->end();++p1) This LINE RIGHT HERE->>>> p1->payload->getX();
Try (*p1)->payload->getX();
Keep in mind: p1 is an iterator; *p1 is the element of the vector it designates; this element is itself a pointer pointing to some element that presumably has a member "payload".
Please, lemme know what you think any feed back is appreciated
--Chad
Best
Kai-Uwe Bux
Chad E. Dollins wrote: Ok same question as before accept this temp trying to call member function with from an index of the vector<TreeNode * > * myMoves error ridden code:
myMoves[x]->makeChildren() ;
You just need to keep track of the types involved:
myMoves is a *pointer* to a *vector* of *pointers*. Thus, first dereference
(now you have a vector) then use the subscript operator (now you have a
pointer), then dereference again to call the member function.
((*myMoves)[x])->makeChildren() ;
Best
Kai-Uwe Bux This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Average_Joe |
last post by:
Hello PHP people,
Was wondering if PHP5 had some sort of "nested class" functionality.
I'm trying to figure out how to return an object (with a private
constructor) that has access to variables in another class.
Something like:
$obj = $factory->getObject("1234");
|
by: Patrick Kowalzick |
last post by:
Dear NG,
I have two containers (standard library) which are nested, e.g.:
std::vector< std::vector <int> > A;
std::list< std::vector<int> > B;
These structures where put in another class which I will name
ComposedContainer<T> for the moment.
|
by: B0nj |
last post by:
I've got a class in which I want to implement a property
that operates like an indexer, for the various colors
associated with the class.
For instance, I want to be able to do 'set' operations like
MyClass.MyColors = Color.Green
or, a 'get', such as
Color forecolor = MyClass.MyColors;
I want to use an indexer so I can take parameters, such
as the color type (e.g. "Foreground", "Background" etc.).
With a single member function I couldn't...
|
by: Robert W. |
last post by:
I've almost completed building a Model-View-Controller but have run into a
snag. When an event is fired on a form control I want to automatically
updated the "connnected" property in the Model. This works fine if all of
the properties are at the top (root level) of the model but I'd like to keep
them in nested classes to organize them better.
So, for example, part of my data model looks like this (simplified) :
public class MainClass
|
by: D. Shane Fowlkes |
last post by:
Hey guys....I tried Googling and search these forums before posting but
couldn't find really what I was looking for. I'm looking for a very simple
example or tutorial on how to nest Repeaters in VB.NET. It seems everything
that I'm finding is in Csharp or is just incredibly complicated using VB by
decalring a dozen classes and such (too complex for my simple brain).
I already have my two queries written and the HTML structure written...
| |
by: Bob Day |
last post by:
Using VS2003, VB.NET, MSDE...
I am looking at a demo program that, to my surprise, has nested classes,
such as the example below. I guess it surprised me becuase you cannot have
nested subs, and I am not sure why you would want nested classes anyway.
Is there a URL that explains the advantages to nested classes, when they
would be used, etc? What are your thoughts?
Also, if a Class has nothing before it (i.e. no Public or Private,...
|
by: ali_tofigh |
last post by:
Hi everyone,
I have a templated class with a nested class inside it. I'm trying to
define an equality operator for the nested class, one that will work
with STL-algorithms and containers. The code below shows the structure
of my program. I have tried several other approaches with no success.
Any insightful thoughts are most appreciated.
Regards,
ALiX
|
by: pagekb |
last post by:
Hello,
I'm having some difficulty compiling template classes as containers for
other template objects. Specifically, I have a hierarchy of template
classes that contain each other. Template class B has an instance of
template class A, which has some base type T (usually int or double).
However, the base type T is important to calculations in B, so I would
like to obtain access to the type for further variable declaration
within B. ...
|
by: desktop |
last post by:
I have 3 types of objects: bob1, bob2 and bob3. Each object is
identified by a unique ID which gets returned by the function getId().
All bobs are descendants from class BaseBob which is an abstract class
that has the virtual function getId().
I then have a function that prints a special string when a bob meets
another bob (all combinations of bobs has to meet and since the are
schizophrenic they can also meet themselves):
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |