473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

[VS2005] class variable members marked as initonly

Hi,

The following C++ managed console application compile with no errors
or warning even if the readonly class members are not explicitly
initialized.

Is there any way to force the compiler to inform me that the readonly
class members are not explicitly initialized?

If I translate this program to C# using 'readonly' instead of
'initonly' the compiler returns me a warning for each readonly member
that is not expliciply inizialized.

TIA.
Marco.

///////////////////////////////////////////

#include "stdafx.h"

using namespace System;

ref class Hello
{
};

ref class TestInitOnly
{
public:
TestInitOnly()
{
}

initonly int i_;
initonly Hello^ h_;
};

int _tmain()
{
TestInitOnly^ init = gcnew TestInitOnly();
}
Nov 17 '05 #1
2 1032
Hi Marco,
The following C++ managed console application compile with no errors
or warning even if the readonly class members are not explicitly
initialized.

Is there any way to force the compiler to inform me that the readonly
class members are not explicitly initialized?

If I translate this program to C# using 'readonly' instead of
'initonly' the compiler returns me a warning for each readonly member
that is not expliciply inizialized.


AFAIK, there's not such a warning currently implemented, and the compiler
will initialize the field to the default value (0/nullptr). You might want
to post a feature request on the msdn feedback center for this!

--
Tomas Restrepo
to****@mvps.org
http://www.winterdom.com/
Nov 17 '05 #2
(no offence) Herb Sutter says, if I recall that, "C++ trusts developer"
:)

Ismail

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: kuvpatel | last post by:
Hi I want to refer a class called LogEvent, and use one of its methods called WriteMessage without actually having to create an instance of Logevent. I have tried using the word sealed with...
5
by: Chris | last post by:
Hi, I don't get the difference between a struct and a class ! ok, I know that a struct is a value type, the other a reference type, I understand the technical differences between both, but...
5
by: Felix I. Wyss | last post by:
Good Afternoon, I recently noticed that some very simple methods of a template declared and used in a DLL library get inlined when used by the DLL itself, but not by other DLLs and EXEs. After...
6
by: al jones | last post by:
I picked a good project to try to learn to use VS - and up till now everything has worked the way I expect. The code is from a VS.net class, which I picked up on the web, from which I've extracted...
7
by: **Developer** | last post by:
Public Shared Sub junk... Dim PF2 As Wnd.PARAFORMAT2 PF2.cbSize = Marshal.SizeOf(PF2) 'ERROR HERE PF2.dwMask = Wnd.PFM_LINESPACING ....snip
16
by: Edward Diener | last post by:
After spending more than a day reducing a complicated compiler bug to a simple case I reported it to the MSDN Product Feedback Center as a bug just now. However this bug is completely stymying my...
8
by: BK | last post by:
Converting a rather large solution from 2003 to 2005. All the errors are worked out, but I'm trying to clean up the warnings as best I can. The good news is that the application and it's...
8
by: Bern McCarty | last post by:
I have a simple ref class in its own namespace that needs to coexist with a legacy typedef alias for "unsigned int" in the global namespace that has the identifier as itself. Everything compiles...
12
by: lee.crabtree | last post by:
In C#, an array marked 'readonly', as in: public readonly bool array = new bool; would allow individual members of the array to be modified while protecting the array reference itself from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.