473,657 Members | 2,456 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help with static struct class definition

This is probably an easy answer but since I am fairly new to C++ for
some reason I can't see it :-( Any help would be appreciated
:-)

I have a class:

class AClass
{
public:
Sep 23 '05 #1
3 1703
SteveM wrote:
This is probably an easy answer but since I am fairly new to C++ for
some reason I can't see it :-( Any help would be appreciated
:-)

I have a class:

class AClass
{
public:
.
. (some functions)
private:
struct PData
{
static int aValue;
static int bValue;
}
Missing a semicolon here
}
And here

I am clueless as to how to format the definition.
What do you mean by "format the definition"?
Everything I have
tried up till now has been flagged by the compiler
Flagged how?
Please Help

BTW What I am needing to do is make the variables of the struct
available to static functions (in public of this class).
Aren't they? Since PData is a member, it should be available, and since
its members are public (by default), they should be available as well.
if I need to
make the struct static also or just need the struct static but not the
members I really dont care. The ultimate goal here is to 1.) get
something to work 2.) Get a better understanding of how C++ does things
(such as static structs or static members of structs)


Read FAQ 5.8.

V
Sep 23 '05 #2
On Fri, 23 Sep 2005 09:20:58 -0700, SteveM wrote:
This is probably an easy answer but since I am fairly new to C++ for
some reason I can't see it :-( Any help would be appreciated
:-)

I have a class:

class AClass
{
public:
.
. (some functions)
private:
struct PData
{
static int aValue;
static int bValue;
}
}

I am clueless as to how to format the definition. Everything I have
tried up till now has been flagged by the compiler
Please Help


In a CPP file:

int AClass::PData:: aValue;
int AClass::PData:: bValue;

You can also initialize them:

int AClass::PData:: aValue = 42;
int AClass::PData:: bValue = 314;

- Jay

Sep 23 '05 #3
Thanks Jay,

That is exactly what I was needing :-)

Also sorry to Victor for the unclear way in which I presented my
problem :-(
I will try to be more clear in the future. I did miss some things in my
attempt at
explaining the problem. sorry

-Steve :-)

Sep 23 '05 #4

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

Similar topics

12
2743
by: Kristian Bisgaard Lassen | last post by:
Hi, How do I parameterize a template by a a allocated array of integers, which is declared static and constant, so I can make compile time optimizations depending on the content of the array. The way I have written my code makes g++ complain about it not being static. BTW I am new to the C++ language and also the templates it provides. Here is an example of what I want to do
15
2527
by: Robin Eidissen | last post by:
What I try to do is to iterate over two variables using template metaprogramming. I've specialized it such that when it reaches the end of a row ot starts on the next and when it reaches the last row it stops.. At least that's what I thought I did, but VC71 says "warning C4717: 'LOOP<0,1>::DO' : recursive on all control paths, function will cause runtime stack overflow". What's wrong? Here's the code: template<int M, int N>
24
2754
by: Steven T. Hatton | last post by:
In the following code, at what point is S::c fully defined? #include <iostream> using std::cout; using std::endl; using std::ostream; class C { int _v;
2
1389
by: asetofsymbols | last post by:
Hi i'm new to c++ i have the class num for big unsigned numbers it seems work ok until now and i want extend the numbers to big-signed and big-float typedef struct{ unsigned len; unsigned* n; }num_;
8
8432
by: Ganesh Kundapur | last post by:
Hi all, struct test { static int x; }X; main() { X.x = 100; }
7
1878
by: Eric Johannsen | last post by:
Hi, My C# code is calling VB6 code, which expects all (fixed-length) strings to be padded with spaces. The strings are contained with a struct, something like this (attributes to simulate fixed-length in C# omitted for brevity): struct MyStruct { int someValue; string myString;
5
3904
by: Hendrik Schober | last post by:
Hi, we just run into the problem, that "default" alignment in the project properies dialog seem to be different. We have a project that's a DLL, which is linked with a couple of LIBs. All are with the same solution. All had "Default" set in the "Struct Member Alignment" entry. After some assembler debugging we found out that a struct member that is a member function pointer in
1
1811
by: weixian_shen | last post by:
I'm trying to call my DLL written in C, and got the error: "Cannot marshal field 'b' of type 'mystruct': There is no marshaling support for this type." The 2 functions in the DLL are: void unpack(mystruct* str, void* in_buf); void pack(mystruct* str, void* out_buf); The data structure is as follows: typedef struct
1
2356
by: mathieu | last post by:
Hello there, I am playing around with template metaprograming: I am trying to redefines my own types. But I am facing a small issue, where I cannot describe the whole implementation in one single class. Instead I have to separate implementation for binary and ascii in two different classes as I don't know how to use the traits technique for constructors. Any pointers very welcome !
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8603
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7320
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1604
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.