Re: return const and assert

From: Victor Bazarov (
Date: 02/20/04

Date: Fri, 20 Feb 2004 02:49:30 GMT

"alexhong2001" <> wrote...
> When to return a const, from either a member function of a class or
> non-member?

When returning by value, 'const' really isn't of any use. It's
basically like adding 'const' when passing by value: means almost

> Is assert() only executed in debug mode but skipped in release mode?

Using your terminology, yes.

> I
> don't see much usage of "assert()." Am I missing its importance?

Probably. 'assert' is a debugging tool for code where you don't
want to have a run-time check once you cleaned everything up.


Relevant Pages

  • Re: Funky function
    ... >> It makes it possible to call this member function on a const object ... >> object may or may not be const). ... int Data; ... in the next line you try to call a function foo on MyData. ...
  • C++ errors
    ... from `const void*' to ` ... member function `static ... char*, unsigned int, const ...
  • Re: const class member function
    ... >> Declaring a member function with the 'const' keyword ... > Is this "const" keyword info for function caller or it is ... invoked only for nonconst objects. ...
  • Re: How to cast from const to non-const
    ... the constness rules are in general enforced by the compiler. ... >> every API that it uses must also be const correct. ... >> member function, for example, where a member function that is logically ...
  • Re: why can a static function not be const? C2272
    ... Marking a member function of class A as const means that 'this' pointer ... Now, a static member function doesn't have 'this' pointer, so marking it ... What makes you think a member const function promises not to modify ...