15,898,371 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by xumepoc (Top 17 by date)
xumepoc
15-Aug-15 14:37pm
View
>Your original question was about avoiding the list class, which is the second class, right?
>Why do you want that? Basically what you are expecting here is what we call unexpected. You may take the data out of a node and keep that in some other class, but keeping a node is an entirely different thing. A node contains data and pointers to its next and previous nodes in the linked list. How do you plan to ensure that the Next and Previous of such a node are valid pointers? Who will be responsible for deleting this node? How will you ensure that this node is not stored in some other objects too?
Well regarding the list class, what I meant was that this class will do the insertion, but will not store the nodes and will not be the one responsible for the memory management. The linked list will be created once based on a specific event and on the second event, will remove the entire list and create it again. But after reading you second question I see that this will be a problem, because there is no way as you said that the third party class using one node will have a valid node or one that was deleted on the rise of the event.
>Basically Node is a class and previous node, current node and next node are different objects of the same class. When you allocate memory for *prev and *next from node, you are actually asking one 'object' of a class to create other 'objects' of the same class which spoils the basic purpose of classes and objects.
More over how do you plan to implement this functionality in a Node? And how do plan to manage these objects? Who will keep track of the objects and how? Who will be responsible for deleting these objects? What happens to the next and previous of a node when the node dies? When a node, say node1 creates its previous (say node0) and next (node2) nodes, how do you plan to manage the previous and next part of node0 and node2 (the next of node0 and prev of node2 should be node1)?
This basically was my question if this was possible and if yes how :) :) :)
I really appreciate you taking from your time answering my questions, I guess I really need to use linkedlist class and node class and work with that....:)
xumepoc
14-Aug-15 1:26am
View
Is it mandatory to have a reference to the head and tail node? Shouldn't they be just null? Surly I can find them easy with a simple while loop until reaching the null element?
A second class will take care of the insertions to the list. But I need a Node to live beyond the life of that second class. So let say I have the LinkedList class creating a list of 5 nodes. I need to pass the first node to a another class and store it there. But then if the LinkedList is destroyed and it was his responsibility for the memory management it will delete also that first node, resulting in a unexpected behavior.
Can you explain if possible, why is it wrong and not advisable for the node to create it's prev and next elements? And for the creation of the first Node responsible will be the same class from above.
xumepoc
13-Aug-15 8:39am
View
I have read that example, but it is not helping me with the problem I have. I need the Node class to be "standalone". I need example with the allocation of the "next" node performed in the Node class itself. I know the idea and the basic implementation of the linked list, but I can't wrap my mind around the memory allocation when you add new node, when you need to free the memory in the destructor, the memory and node management in "operator=" and copy constructor.
xumepoc
13-Aug-15 8:21am
View
I did, but all I could find were examples with LinkedList class...
xumepoc
10-Aug-15 6:48am
View
And for the deep copy function and the operator= I just need to loop over and use the add to back routine? Also the deconstruct function should do the same, but just delete the next correct?
xumepoc
4-Apr-15 7:28am
View
What other methiod to use in otder for the "child" class to have access to the parent? Referance variable?
xumepoc
3-Apr-15 12:10pm
View
My problem is that I need the child variable (in the example above Boo *b) to have access to the parent Foo.
I will post a sample code later tonight.
xumepoc
3-Apr-15 9:50am
View
Sorry I am really bad in explaining thnings :D
That is what I mean:
class Boo;
class Foo
{
public:
Foo();
virtual ~Foo();
Foo(const Foo& cop);
Foo& operator=(const Foo& cop);
private:
Boo* b;
}
#include "Boo.h"
Foo::Foo()
{
}
Foo::~Foo()
{
delete b;
}
Foo:Foo(const Foo& cop)
{
delete b;
b = new Foo();
b = cop.b;
}
Foo& Foo::operator=(const Foo& cop)
{
delete b;
b = new Foo();
b = cop.b;
return *this;
}
class Foo;
class Boo
{
public:
Boo();
virtual ~Boo();
Boo(const Boo& cop);
Boo& operator=(const Boo& cop);
private:
Foo* f;
}
#include "Foo.h"
Boo::Boo()
{
}
Boo::~Boo()
{
delete f;
}
Boo:Boo(const Boo& cop)
{
delete b;
f = new Boo();
f = cop.f;
}
Boo& Boo::operator=(const Boo& cop)
{
delete f;
f = new Foo();
f = cop.f;
return *this;
}
Is this correct or there are problems. I know that I have to pass either f or b as a reference because I will create a loop.
xumepoc
3-Apr-15 9:12am
View
My bigger problem in the deep copy constructor and operator= should I do:
delete pointer;
pointer = new Pointer();
pointer = cop.pointer;
where "pointer" is a pointer variable, and the cop is the (const Pointer& cop).
Also I should delete the pointer on the deconstructor, right?
xumepoc
17-Jan-14 8:51am
View
Thank you Richard, I will give it a try:)
xumepoc
17-Jan-14 6:26am
View
Can I do this: add a string to the CArchive before serialize the class. And then on the other end first read the string and then deserialize to the class?
xumepoc
17-Jan-14 5:26am
View
Well my question was if I can have a second TCP on different port to only indicates that the next incoming data is of data1 let say.
If I include the header, it will be part of the data structure itself? So on the deserialization with CArchive the first thing it will do is get the header, correct?
xumepoc
17-Jan-14 5:02am
View
So basically it is not possible. In order to do that, I have to have a second connection via which I have to tell the other side what kind of data to expect. The thing is we are talking about time critical data, so how to be sure that the indication will always arrive before the data connection
xumepoc
17-Nov-13 14:52pm
View
Thanks for the reply,
yes by refresh I do mean invalidate, but I need to do that every second or mouse move/action.
I have tried Direct2D, but for some reason it is too slow, many times slower then pure GDI.
xumepoc
29-Oct-12 10:30am
View
Any One? :D
xumepoc
1-May-12 14:52pm
View
Copied, sorry
xumepoc
9-Apr-12 6:46am
View
Copied. Thanks again for the reply, it is appreciated :)
Show More