Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 429 results for
polymorphic
- Page 1
Polymorphic Queue
Programming
Software Development
15 Years Ago
by metdos
Hello Everyone, I'm trying to implement a
Polymorphic
Queue. Here is my trial: [CODE]QQueue <Request *>…decodeFromTcpMessage(); } }[/CODE] Unfortunately, I could not manage to make work
Polymorphic
Queue with this code because of the reason I mentioned… improvement of my code or a new implementation of
polymorphic
queue. Thanks.
Polymorphic write-to-file with abstract inheritance problem (not as bad as it sounds)
Programming
Software Development
14 Years Ago
by lacoffo
… Java and I'm having a little trouble on a
polymorphic
write-to-file function. Let me quickly explain my project… Main program I should be able to call this function
polymorphic
like array[index].WriteData(), and each Horse and Cow should…
Polymorphic Virus
Hardware and Software
Information Security
16 Years Ago
by Seakros
… that it might be a [COLOR="Green"]"
polymorphic
"[/COLOR] virus (which apparently changes itself everytime it is…
Passing polymorphic pointer by reference to function
Programming
Software Development
14 Years Ago
by TheWolverine
… I am struggling with how to working with a
polymorphic
pointer as a function input parameter, by reference. … protype for setParameterOfDerivedClass() I want to use a
polymorphic
pointer to be able to pass objects of DerivedClass… trying to avoid doing that by using the
polymorphic
pointer. Any feedback would be greatly appreciated. Thanks!…
Policy vs polymorphic timing
Programming
Software Development
13 Years Ago
by daviddoria
… tight loop is much faster than using a
polymorphic
function. However, I setup this demo and…The policy version takes between 2-3x longer than the
polymorphic
version. [code] #include <iostream> #… const float b) { return a + b; } }; //
Polymorphic
version class DoOperation { public: virtual float Run(const float a…
Help(polymorphic variables in java)
Programming
Software Development
17 Years Ago
by java.cream
Hi all, I need help in
polymorphic
variables concept ,Are there any
polymorphic
variables in the code belowand Explain why? thnks.. [CODE]class…
Re: Passing polymorphic pointer by reference to function
Programming
Software Development
14 Years Ago
by TheWolverine
… here. My question pertained particularly to the idea of passing
polymorphic
pointers to functions, and I've now figured out how…
Re: Policy vs polymorphic timing
Programming
Software Development
13 Years Ago
by mike_2000_17
… is due to the side-effect of creating a dynamic
polymorphic
object, while the static case probably determines that the entire…
Re: Policy vs polymorphic timing
Programming
Software Development
13 Years Ago
by m4ster_r0shi
… OperationPolicyDiv { double Operation(double a, double b) { return a / b; } }; //
polymorphic
version struct DoOperation { virtual double Run(double a, double b…
What is needed for a C++ member function of a class to behave polymorphic?
Programming
Software Development
16 Years Ago
by viki0077
What is needed for a C++ member function of a class to behave
polymorphic
? Please can anyone answer me to this, and if you can give me some example. Thanks.
Re: What is needed for a C++ member function of a class to behave polymorphic?
Programming
Software Development
16 Years Ago
by Danny_501
Look at the C++ section of this link: [URL="http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming#C.2B.2B"]wiki: Polymorphism_in_object-oriented_programming[/URL] I guess the talk() function is behaving
polymorphic
, because its in each of the inherited classes.
Re: What is needed for a C++ member function of a class to behave polymorphic?
Programming
Software Development
16 Years Ago
by NicAx64
…: Polymorphism_in_object-oriented_programming[/URL] I guess the talk() function is behaving
polymorphic
, because its in each of the inherited classes.[/QUOTE] No…
Re: Polymorphic Queue
Programming
Software Development
15 Years Ago
by Banfa
The problem is at line 12 loginRequest is created on the stack, that means that it is automatically has the lifetime of the code block it is in which is the if statement. You take pointers to it and put them on your queue but that doesn't change the fact that the original object is deleted when its lifetime expires. You need an object whos …
Re: Polymorphic Queue
Programming
Software Development
15 Years Ago
by metdos
Yes it is a QT class, I used it just for coherence.
Re: Polymorphic Queue
Programming
Software Development
15 Years Ago
by metdos
[QUOTE]Change how you use your queue so that the pointers it contains always point to objects allocated using new. When you remove items from the queue remember to delete them once you are finished with them. Possibly look into using std::auto_ptr or a smart pointer or handle class.[/QUOTE] Can you give an example?
Re: Polymorphic Queue
Programming
Software Development
15 Years Ago
by thelamb
You have already done it... Look at how you declare your 'request': [code]Request *request=new Request();[/code] So 'request' is now allocated on the heap.. means you are responsible for cleaning it up (delete request; somewhere in the code). Then, you say.. ok I want 'request' to point to a LoginRequest. [code]LoginRequest loginRequest;…
Re: Polymorphic Queue
Programming
Software Development
15 Years Ago
by metdos
[QUOTE]So I dont really understand why you do the first "new Request();".. doesnt this make more sense:[/QUOTE] Because at that level I don't know which subclass is it, and if statements will continue like this: [CODE]# if(request->requestType==REQUEST_LOGIN){ LoginRequest loginRequest; request=&loginRequest; requests.…
Re: Polymorphic Queue
Programming
Software Development
15 Years Ago
by Banfa
Actually this piece of code is not really interested in the sub-class at all. It just needs a Request* in order to queue the request. It looks like you could use a factory method. A factory method is often a static member of a base class that accepts data and uses the data to create a sub-class of that base but returns a base class pointer.…
Re: Polymorphic Queue
Programming
Software Development
15 Years Ago
by metdos
This version solved my problem. [CODE]QQueue <Request *> requests; while(...) { QString line = QString::fromUtf8(client->readLine()).trimmed(); if(...)){ Request *request=new Request(); request->tcpMessage=line.toUtf8(); request->decodeFromTcpMessage(); //this initialize variables in …
Re: Polymorphic write-to-file with abstract inheritance problem (not as bad as it sounds)
Programming
Software Development
14 Years Ago
by JamesCherrill
I would pass the PrintWriter as a parameter to all the WriteData methods. So it's created and closed in the same place as the loop (eg your Main program).
Re: Polymorphic write-to-file with abstract inheritance problem (not as bad as it sounds)
Programming
Software Development
14 Years Ago
by lacoffo
Worked like a charm :) Thanks a lot man:)
Re: Polymorphic Virus
Hardware and Software
Information Security
16 Years Ago
by Seakros
I forgot to add that I tried to install Vundofix but it is not installing for some reason. At the very end of the process it just stops, tells me there is an error and uninstall the components it installed.
Re: Polymorphic Virus
Hardware and Software
Information Security
16 Years Ago
by smith_
use superantispyware may be it will help you fee download here >[url]http://www.superantispyware.com/[/url]. if you get still problem go SNIP
Polymorphic Problem
Programming
Software Development
15 Years Ago
by BobTheLob
Okay, so i've been trying to get this code to work for quite some time, and i'm about to go bonkers. Hopefully y'all can help me out with this problem because I need to hand this one in soon. My problem is I need to make an array of objects. Check. (Note that the classes i'm using extend a superclass, Ship). Now I need to set information into …
Re: Polymorphic Problem
Programming
Software Development
15 Years Ago
by moutanna
Hi Can you provide the code of the Ship class please?
Re: Polymorphic Problem
Programming
Software Development
15 Years Ago
by BobTheLob
[CODE]public class Ship { public String shipName; private String yearBuilt; public void setName (String n) { shipName = n; System.out.println("Inside the setName Super"); } public void setYear (String y) { yearBuilt = y; System.out.println("Inside the setYear Super"); } public String toString () { …
Re: Polymorphic Problem
Programming
Software Development
15 Years Ago
by moutanna
You have this declaration in the Boats calss Ship[] type = new Ship[2]; and the Ship class have no methode with the setMax; in facte this method is declard in the CruiseShip Class. So itis not permited to call it over the type[1] even if you do this instructio: type[1] = new CruiseShip(); To avoid this move the function setMax with it'…
Re: Polymorphic Problem
Programming
Software Development
15 Years Ago
by moutanna
Another alternative is to declare the Ship class as abstract with some setMax as abstract function. you need also to move the maxPass to the Ship class with the protected modifier.
Re: Polymorphic Problem
Programming
Software Development
15 Years Ago
by moutanna
the second proposition result in many changes
Re: Polymorphic Problem
Programming
Software Development
15 Years Ago
by BobTheLob
Excellent. However, in the project description, I need to have a CruiseShip class that extends the Ship class. And then I need to demonstrate the multiple classes I made in a program with a Ship array. And then assign various Ship, CruiseShip, and CargoShip objects to the array elements. So how would I go about doing this?
1
2
3
8
Next
Last
Search
Search
Forums
Forum Index
Hardware/Software
Recommended Topics
Programming
Recommended Topics
Digital Media
Recommended Topics
Community Center
Recommended Topics
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Top Members
Meet People
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2025 DaniWeb® LLC