🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by keith Fri, 07 Mar 1986 20:11
Is this a C++ bug?
#76
Author: keith
Date: Fri, 07 Mar 1986 20:11
29 lines
1120 bytes
A member of a const argument cannot be used as a const argument in a
function call:

class Foo { int i; };

class Bar {
	Foo foo;
public:
	void g(const Foo&);
	void f(const Bar& b)	{ g(b.foo); }	// gets error
};

"constbug.c", line 7: error: address of member Bar::foo of const Bar 

Is this a bug in C++ Release 1.0 or a "feature"?

Incidentally, you can get around this with an explicit cast:

	{ g(((Bar*)&b)->foo); }

-- 
---
	Keith Gorlen
	Computer Systems Laboratory
	Division of Computer Research and Technology
	National Institutes of Health
	Bethesda, MD 20892
	phone:	(301) 496-5363
	uucp:	{decvax!}seismo!elsie!cecil!keith
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads