[Qt-interest] struct & class

navid navid n_nnavid at yahoo.com
Tue Nov 17 08:13:59 CET 2009


if it is possible, please provide me with an example for definition of a constant structure variable 



----- Original Message ----
From: Ross Driedger <ross at earz.ca>
To: navid navid <n_nnavid at yahoo.com>
Cc: qt-interest at trolltech.com
Sent: Tue, November 17, 2009 9:04:57 AM
Subject: Re: [Qt-interest] struct & class

On Tue, 17 Nov 2009 00:07:56 -0500, navid navid <n_nnavid at yahoo.com> wrote:

> Dear Ross
> 
> Thanks for favor.
> bay the way, I till can not find on the web how to define a constant struct. the following code produce error:
> const SETPOINT unsuccess_setpoint={0.0,0,0.0,0};
> also, when define {const SETPOINT unsuccess_setpoint;}, it is impossible to initialize members at constructor.

No, that will not work.

To make an object const, you declare it as such and use the constructor you want.  That constructor must use its intitalization list.  But that kind of use is fairly rare.

Const objects usually come into play when accessing existing objects through const references or pointers.

Ross

--
"Wagner's music has some wonderful moments but awful half hours. "
Gioacchino Rossini


Ross Driedger
ross_at_earz.ca



      



More information about the Qt-interest-old mailing list