|
You certainly do not need to start with 10,000,000 element arrays reserved in memory. You also seem confused about how to handle data streams. You have opened an input stream and then an output stream, but you never use either of them. You are also trying to use a character array as a stream.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I know if I have a class like that
class A
{
shared_ptr<SomeType> data;
}
I don't need to declare a destructor, as the compiler will automatically write one for me that take care of everything.
But what if I have a resource without a destructor, such as a handle.
I need to implement a destructor
class A
{
shared_ptr<SomeType> data;
HANDLE wndobj;
~A() {
CloseHandle(wndobj);
}
}
Do I need to handle all variable? or only those without destructor (i.e. wndobj)?
I.e. what of data?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Good question, if your class allocated the pointer, but shared it with other classes, then you will need to reference count it and olny delete the allocation when the last reference is removed.
==============================
Nothing to say.
|
|
|
|
|
it's a shared_ptr! the reset method is here for that, it decrease ref count.
so, if I get you right, when I declare my own explicit destructor I do need to call all the destructor of my properties? but I didn't use new... (as in ComPtr<t> that I get through a query) mmm .. I guess I set those to null..
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Super Lloyd wrote: but I didn't use new...
That has nothing to do with it.
The use of 'new' is specific to a certain kind of finite resource (memory).
Your class on the other hand must manage ALL of the resources that it owns. So it must clean it up.
|
|
|
|
|
I wrote a little test program to answer all my questions!! :P
To answer the one on this page, no need to call .reset()!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
I think that what Eric meant above was that if you share the resource handle through the shared_ptr then you should not CloseHandle prematurely, when others still are using it. Thus you need to examine the ref count before CloseHandle, or else you will have invalid objects.
Life is too shor
|
|
|
|
|
Errr, we're talking about the destructor and said shared_ptr object is about to be destroyed - it doesn't have to be reset! Would be a dumb kind of smart pointer if you still have to tell it to decrease the reference before destroying it...
|
|
|
|
|
A little test program clarified everything! ^^
All non pointer member's destructor get called at all time, whatever else might be...
I was just not sure initially! ^^
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Yes, I was talking generally and as you say the shared_ptr class does this for you so no need to worry about it.
As for things like handles, in your example, it is best to call a close on them before your class destructor is called, ie, do your tidy up as early as you can.
==============================
Nothing to say.
|
|
|
|
|
The destructor will be called on data, so there's no need to call reset.
Steve
|
|
|
|
|
Thanks!
Indeed I though of writing a test program and found that out too!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Helo i want to implement fuzzy logic code in C++ and i am new in it can any one help me plz i need urgent help
|
|
|
|
|
This is not a good question as you have really not described what you are trying to do. Try a Google search first and read some information on the subject.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
i have done alot of search on it and i need to implement it immediately.
|
|
|
|
|
What does that mean? Do you think that there is a simple formula or algorithm for Fuzzy Logic?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
no there is proper procedure for that but what is your clever thinking actually i have to make something new i am implementing fuzzy logic to improve movement of my robot as there is so much disturbed walk of robot in through dead reckoning code so i have to remove it and then i have to generate something new if u can help i'll be very thankful
|
|
|
|
|
Sorry, buy I have no idea what you are doing or what code you are using. If you want help with specific issues in your code then you need to explain exactly what your problem is. As I said before, this is not just a matter of adding a simple formula or algorithm.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
i am implementing fuzzy logic on robot to make its drive straight
|
|
|
|
|
Your request is wrong on so may levels. For starters, AI/fuzzy logic is not a beginner's subject matter, especially if they are also learning C++.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I know a company you can work for whose code seems to be nothing but fuzzy logic.
|
|
|
|
|
robot29 wrote: Helo i want to implement fuzzy logic code in C++
You need to drink quite a lot of alcohol to achieve this. And then write a lot of code, very fast.
Next day you will look at what you wrote, and it wont make sense and might work...
|
|
|
|
|
|
You should at least tell us what is your problem (that is what problem are you trying to solve using fuzzy logic and what are your troubles with it).
Veni, vidi, vici.
|
|
|
|
|
i am implementing fuzzy logic for allignment of my robot drive so that it will drive smoothly i am implementing an IEEE research paper in which they have used it and that i am implementing .
|
|
|
|