Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error C2514

Status
Not open for further replies.

Nosferatu

Programmer
Jun 9, 2000
412
RO
Hy guys!

I'm preety new in C++ world and right now (actually since yesterday) i keep getting this compiler error form MSVC6 and it makes my hair turn white...
The error text is:
error C2514: 'NamedNodeMap' : class has no constructors
But, the class HAS constructors and i get this error when i try to create dinamically a new object:

b = new NamedNodeMap(source).

This should use the class copy constructor which is also defined.

here-s the class declaration:
Code:
class NamedNodeMap {
private:	
	ulong		length;
	PNodeList	list;
public:
	NamedNodeMap();
	NamedNodeMap(const NamedNodeMap& src);
	virtual ~NamedNodeMap();

	// Level 1
	PNode getNamedItem(DOMString name);
	PNode setNamedItem(PNode arg);
	PNode removeNamedItem(DOMString name);
	PNode item(ulong index);

	//Level 2
	PNode getNamedItemNS(DOMString namespaceURI, DOMString localName);
	PNode setNamedItemNS(Node arg);
	PNode removeNamedItemNS(DOMString namespaceURI, DOMString localName);
};

In a separate header file I defined:
Code:
 typedef class NamedNodeMap * PNamedNodeMap;
and what i'm trying to do is to create a new PNamedNodeMap object.

I have to tell you that i have some 22 (!) other classes in the project, all of them defined in this way and i only get the error for this class. Any help would be highly appreciated!

Thank you!

P.S. I just figgured out something but i'm not sure about this: the source passed to NamedNodeMap si a pointer (like the one defined above). I know that the copy constructor gets a reference, but shouldn't passing a pointer solve the problem? Nosferatu
We are what we eat...
There's no such thing as free meal...
 
where did you implement constructors? John Fill
1c.bmp


ivfmd@mail.md
 
if you are using

PNamedNodeMap nnm = new PNamedNodeMap;

I think your problem is here. It should be

PNamedNodeMap nnm = new NamedNodeMap;

Matt

 
I am using the copy constructor as above:

Code:
b = new NamedNodeMap(source)

The constructors are in a separate file included in the project. Anyway, if they are not implemented (default and copy constr) shouldn't the compiler suply me with the default constructors? but again, that's not the problem, i have defined and declared the constructors.




Nosferatu
We are what we eat...
There's no such thing as free meal...
 
they are just EMPTY! I have not really implemented them yet, i don't need to do that right now. So there are no errors in the constructors!

The call is just what i wrote before...

Here:
Code:
attrs = new NamedNodeMap;//new NamedNodeMap(src.attrs);
If i try the commented line i get the error C2514. If i try the first one i get: C2512...
I simply don't understand what's wrong!
Here is the class definition for the class i'm calling the cosntructor from (it's a class for DOM):
Code:
class Node {

	// Level 1
	DOMString		nodeName;
	DOMString		nodeValue;
	ushort			nodeType;
	PNode			parentNode;
	PNodeList		childNodes;
	PNode			firstChild;
	PNode			lastChild;
	PNode			prev;
	PNode			next;
	PNamedNodeMap	attrs;
	PDocument		owner;

	// Level 2 add-ons
	DOMString		namespaceURI;
	DOMString		prefix;
	DOMString		localName;
	friend			DOMUtils;
	

public:
	
	Node(ushort type, DOMString name, DOMString value);
	virtual ~Node()	{
		if (nodeName)
			delete []nodeName;
		if (nodeValue)
			delete []nodeValue;
	};
	Node(const Node& src);			// copy constructor
	//Level 1
	PNode cloneNode(boolean deep);
	PNode insertBefore(PNode newChild,PNode refChild);
	PNode replaceChild(PNode newChild,PNode oldChild);
	PNode removeChild(PNode oldChild);
	PNode appendChild(PNode newChild);
	boolean hasChildNodes();
	
	//Level 2 add-ons
	boolean isSupported(DOMString feature,DOMString version);
	boolean hasAttributes();
	void normalize();		// removed from Element interface
};

And the call is in the following method:
Code:
Node::Node(const Node& src)
{	utils->setNodeName(autoref,src.nodeName);
	utils->setNodeValue(autoref,src.nodeValue);
	utils->setNodeNamespaceURI(autoref,src.namespaceURI);
	nodeType = src.nodeType;
	firstChild = src.firstChild;
	lastChild = src.lastChild;
	owner = src.owner;
	next = src.next;
	prev = src.prev;
	childNodes = src.childNodes;
	attrs = new NamedNodeMap;//new NamedNodeMap(src.attrs);
	owner = NULL;
}

Any ideas?
Thank you for your interest...
Nosferatu
We are what we eat...
There's no such thing as free meal...
 
I had similar problems once. I rewrote manually identically the same code lines and it helped. Maybe there are some invisible symbols or something like that. John Fill
1c.bmp


ivfmd@mail.md
 
Maybe there's a new virus that attacks source code, placing 255 ASCII values in source files...
By the time i was in high school, we used to freak-out our Computer Programming teacher by placing a 255 character at the end of a line of code and getting some weird errors from Borland DOS IDE...

Anyway, thanks, i will do that rewriting and hope the thing will eventually compile. Maybe is a MSVC bug... By the way, JohnFill, when that thing happened to you, were you using MSVC? Nosferatu
We are what we eat...
There's no such thing as free meal...
 
it was not a virus. I did a copy/paste from a word document. It wasn't long a go, at my work. John Fill
1c.bmp


ivfmd@mail.md
 
i was just kidding about the virus...

Nosferatu
We are what we eat...
There's no such thing as free meal...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top