Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Derivating from Vector<>
Derivating from Vector<> [message #8343] Sat, 03 March 2007 20:12 Go to previous message
victorb is currently offline  victorb
Messages: 78
Registered: December 2005
Location: Nice, France
Member
I am trying to derivate a class from Vector<...> but I can't get it to work. Any help from the Upp community would be welcome.

Here is some sample code:

#include <Core/Core.h>

using namespace Upp;

class IntVector : public DeepCopyOption<IntVector, Vector<int> >
{
public:
	IntVector(){Cout() << "IntVector\n"; }
	
	virtual ~IntVector(){Cout() <<  "~IntVector\n";}
	
	IntVector(const IntVector &src, int) {
		::new IntVector;
		Vector<int>(src, 0);
		name = src.name;
		Cout() << "DCC\n";				
	}

	String name;
	
	String ToString(void) {
		String dump;
		
		dump << name << " ";
	
		if (IsPicked()) return dump << "Picked";
		
		for (int i = 0; i < GetCount(); i++) {
			dump << At(i) << " ";
		}
		return dump;
	}

};

CONSOLE_APP_MAIN
{
	Cout() << "iv\n";
	IntVector iv;
	
	iv.name = "IV";
	
	iv.Add(5);
	iv.Add(6);
	
	Cout() << "iv2\n";
	IntVector iv2(iv, 0);

	Cout() <<  iv.ToString() << "\n";
	Cout() <<  iv2.ToString() << "\n";

}


I expect iv2 to be equal to iv at the end. There is probably something wrong with the deep copy constructor but I really can't figure it out.

Victor

[Updated on: Wed, 07 March 2007 00:55]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: something abaut brc file
Next Topic: XML Error
Goto Forum:
  


Current Time: Sun Jun 15 02:24:23 CEST 2025

Total time taken to generate the page: 0.05863 seconds