|
Hi,
I made a Stack implementation, and now I'm looking to make the implementation be more generic. I know that the way to do this is probably to use template. I have a cons list of items which is
template <class t=""><br />
class ConsList : public LList<t> {<br />
....<br />
ConsList(T first, LList<t>* rest);
}</t></t></class>
as of now. When I try to make an instance of the ConsList<int> with the new keyword, I get a lot of errors
g++ -o Main LList.o Stack.o Exception.o main.o<br />
Stack.o: In function `Stack::push(int)':<br />
Stack.cpp:(.text+0xaa): undefined reference to `ConsList<int>::ConsList(int, LList<int>*)'<br />
Stack.o: In function `Stack::Stack()':<br />
Stack.cpp:(.text+0xe5): undefined reference to `EmptyList<int>::EmptyList()'<br />
Stack.o: In function `Stack::Stack()':<br />
Stack.cpp:(.text+0x123): undefined reference to `EmptyList<int>::EmptyList()'<br />
collect2: ld returned 1 exit status<br />
</int></int></int></int>
I've googled templates, and it looks like nobody makes a new item that is a template. If there a reason why people don't use this, or how would I go about creating an instance of ConsList<int>(.., ..). Thanks,
-Ken
|
|
|
|
|
Maybe select the "Ignore HTML tags in this message" check box and re-post your code. There are a lot of sad faces in it.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Ken Mazaika wrote: Stack.cpp.text+0xaa): undefined reference to `ConsList::ConsList(int, LList*)'
It seems that you have n't defined the functions of the template classes. At the point of template instantiation the definition of the function should be visible where it is triggered by refering in the code (of stack). May be you declared the template class in a header file which doesnot have definitions (possibly you defined in LList.cpp) and included the header in stack.cpp. But template class requires the definitions also , so add the definitions in LList.cpp to the header itself.
|
|
|
|
|
Thanks for your response. That solved the problem completely. I created a LList.cpp file, which I didn't treat as a header, I added the template definitions to the header and it worked perfectly. Thanks again for your response!
-Ken
|
|
|
|
|
hhmm....how to find the center point of 2 lines using the visual c++. i need to find the center point of a track...actually,i'm using the video instead of static image. i have already got the binary image and stuck at this stage. please help me anyone?
|
|
|
|
|
umai wrote: please help me
Is it urgent?
led mike
|
|
|
|
|
|
umai wrote: how to find the center point of 2 lines
What two lines? What is the center point of two lines?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
let say, there is a track....my mobile robot need to move along the track...the track is about 3 cm width...the reference for the mobile robot is the center point of the track...how can i get the center point?
im using the edge detection method but still cannot find the center point
|
|
|
|
|
The midpoint between two points (x1,y1) and (x2,y2) could be found something like
(xMid, yMid) = ((x1 + x2) / 2, (y1 + y2) / 2)
I imagine for those two points, you'll need points on your detected lines that are perpendicular to the
robot...or something like that.
You'll need to do a little math
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Assuming the track delimiting lines parallel, at every point (of one of the two lines) you have to find the perpendicular line and choose on it the point that is halfway the two lines of the track.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Have you troubles with
(1) C++ language?
(2) Analytic geometry?
(3) Windows programming?
(4) Bitmaps
(5) All of the above stuff?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi,
Do you mean "intersection point of 2 lines"?
If so, find equation of both lines, at the point of intersection both equations are same.
If not, Explain the problem more clear.
Best Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
Very simple!
But you have to explain the scenario clearly...I have done same the thing you have puzzled.
Explain it again!
Thanks a lot
|
|
|
|
|
let say, there is a track....my mobile root need to move along the track...the track is about 3 cm width...the reference for the mobile robot is the center point of the track...how can i get the center point?
|
|
|
|
|
I'm using Visual C++ in VS2008.
It's slow, who knows what it is busy with?
modified on Saturday, March 29, 2008 2:29 AM
|
|
|
|
|
It's speeding up your code-development process.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Probably continuously updating and verifying Intellisense[^]
Best Wishes,
-David Delaune
|
|
|
|
|
time might come for hardware update
|
|
|
|
|
followait wrote: It's slow
Dump it and use Eclipse and stop complaining
led mike
|
|
|
|
|
I'm not complaining.
I'm thinking about the design.
|
|
|
|
|
followait wrote: I'm thinking about the design.
Excellent. You should apply for a position on the VS team. I'm sure they would snap you up!
led mike
|
|
|
|
|
Can Any one explain what is alpha in image processing (particular in DICOM IMAGES)
|
|
|
|
|
|
Did you get a job doing image processing on medical imagery??
|
|
|
|