473,385 Members | 1,912 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,385 software developers and data experts.

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 1698
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
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....
15
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...
24
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
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* ...
8
by: Ganesh Kundapur | last post by:
Hi all, struct test { static int x; }X; main() { X.x = 100; }
7
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...
5
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...
1
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...

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.