473,857 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Static Variable running init

Hi

I have a Problem with my static vector which I defined. I'm using LTIB
Library looks like this:

test.h

class test
{
public:
static lti:channel8 img
}

test.cpp

include .....

lti:channel8 test::img(int sizex,int sizey,(byte) 0)

test::test()... ...
void test::create()
{
sizex = 6
sizey = 7
lti:channel8 test::img(sizex ,sizey,0) //I get the size I need only here
so how do I initialize it correct
}

Anyone has an idea.

Thanks

Patrick
Jul 22 '05 #1
5 1282
On Tue, 26 Oct 2004 10:46:39 +0200, "Patrick"
<th**********@s pamgourmet.com> wrote:
Hi

I have a Problem with my static vector which I defined. I'm using LTIB
Library looks like this:

test.h

class test
{
public:
static lti:channel8 img


Shouldn't this have two colons?

[the rest snipped]

--
Bob Hairgrove
No**********@Ho me.com
Jul 22 '05 #2

"Patrick" <th**********@s pamgourmet.com> wrote in message
news:cl******** **@home.itg.ti. com...
Hi

I have a Problem with my static vector which I defined. I'm using LTIB
Library looks like this:

test.h

class test
{
public:
static lti:channel8 img
}

test.cpp

include .....

lti:channel8 test::img(int sizex,int sizey,(byte) 0)

test::test()... ...
void test::create()
{
sizex = 6
sizey = 7
lti:channel8 test::img(sizex ,sizey,0) //I get the size I need only here
so how do I initialize it correct
}

Anyone has an idea.

Thanks

Patrick


You should define the static members and this should be done outside any
method or function and in the same namespace as the class containing it.
Take this statement outside the create method.

lti::channel8 test::img(sizex ,sizey,0)
And it should be lti::channel8 instead of lti:channel8

Catalin
Jul 22 '05 #3
Hi
The Colons are not the Problem this is only a functional demonstration.
The Problem is how do i init it correct so I get hte right contructor
initialization. Because outside of my function I don't have the right
values.

Patrick

"Bob Hairgrove" <in*****@bigfoo t.com> wrote in message
news:eh******** *************** *********@4ax.c om...
On Tue, 26 Oct 2004 10:46:39 +0200, "Patrick"
<th**********@s pamgourmet.com> wrote:
Hi

I have a Problem with my static vector which I defined. I'm using LTIB
Library looks like this:

test.h

class test
{
public:
static lti:channel8 img


Shouldn't this have two colons?

[the rest snipped]

--
Bob Hairgrove
No**********@Ho me.com

Jul 22 '05 #4
I have a Problem with my static vector which I defined. I'm using LTIB
Library looks like this:

test.h

class test
{
public:
static lti::channel8 img
}

test.cpp

include .....

lti:channel8 test::img(int sizex,int sizey,(byte) 0)

test::test()... ...
void test::create()
{
sizex = 6
sizey = 7
lti:channel8 test::img(sizex ,sizey,0) //I get the size I need only here so how do I initialize it correct
}

Anyone has an idea.

Thanks

Patrick


You should define the static members and this should be done outside any
method or function and in the same namespace as the class containing it.
Take this statement outside the create method.

lti::channel8 test::img(sizex ,sizey,0)
And it should be lti::channel8 instead of lti:channel8

Catalin


Hi

I already did that but I don't have the values of this variables outside of
my create method.

Patrick
Jul 22 '05 #5
"Patrick" <th**********@s pamgourmet.com> wrote in message news:<cl******* ***@home.itg.ti .com>...
I have a Problem with my static vector which I defined. I'm using LTIB
Library looks like this:

test.h

class test
{
public:
static lti:channel8 img
}

test.cpp

include .....

lti:channel8 test::img(int sizex,int sizey,(byte) 0)

test::test()... ...
void test::create()
{
sizex = 6
sizey = 7
lti:channel8 test::img(sizex ,sizey,0) //I get the size I need only here
so how do I initialize it correct
}


A class static variable will be constructed before main() executes. There
is nothing you can do about that.

So, if you don't have the necessary information to properly create the
object until runtime, you have a couple of choices:

1) Instead of having a static object, have a static pointer and new the
object at runtime.

2) If the type supports assignment, construct it with dummy values and then
at runtime, assign an instance constructed with the real vaulues.

Good luck,
samuel
Jul 22 '05 #6

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

Similar topics

1
1484
by: cppaddict | last post by:
I would like to know the best way to initialize complex static member variables. In addition, I want to avoid creating an Init() method that is called by the ctor, since there's no need to wait for that call in my application. My current attempt is OK, but it creates an extra member variable that is extraneous: <code> class A { private: static std::vector<int> _v;
1
3986
by: Bryan Parkoff | last post by:
I know how to write "Pointer to Function" inside struct or class without using static, but I have decided to add static to all functions inside struct or class because I want member functions to be bound inside struct or class to become global functions. It makes easier for me to use "struct.memberfunction()" instead of "globalfunction()" when I have to use dot between struct and member function rather than global function. I do not have...
3
8112
by: paulw | last post by:
Hi I have a question: main() { static int i; printf("%d\n",i); // should I see see 0 or 5 ??? for (i=5;i<=15;i++) {...} // What's the meaning of static variable in
16
3170
by: Ed Sutton | last post by:
I use a mutex to disallow starting a second application instance. This did not work in a release build until I made it static member of my MainForm class. In a debug build, first instance got ownership, second did not and terminated. In a release build, the second instance *also* got ownership. I "fixed" it by making the mutex a static member of my MainForm class. Did the garbage collector eat my mutex because it is not referenced
28
4658
by: Dennis | last post by:
I have a function which is called from a loop many times. In that function, I use three variables as counters and for other purposes. I can either use DIM for declaring the variables or Static. Would the performance be better using Static versus Dynamic. I would think it would be quicker with STATIC declarations since the variables would only have to be created once. Can anyone confirm this. Thanks. -- Dennis in Houston
8
8941
by: Per Bull Holmen | last post by:
Hey Im new to c++, so bear with me. I'm used to other OO languages, where it is possible to have class-level initialization functions, that initialize the CLASS rather than an instance of it. Like, for instance the Objective-C method: +(void)initialize Which has the following characteristics: It is guaranteed to be run
14
2600
by: Jeroen | last post by:
Hi all, I've got a question about writing a library. Let me characterize that library by the following: * there is a class A which is available to the user * there is a class B that is used in severel 'underwater operations' * there is a list which stores objects of class B There are several issues I'm not sure about:
1
1322
by: askcq | last post by:
static int init=0; main() { void func1 (int); void func2 (int); func1(init); func2(init); }
3
1801
by: Bryan Parkoff | last post by:
The local variables and local functions are inside class body. You define a variable to the class "Reg reg;" in the main function. The reg variable has a pointer. The pointer gives memory address. The memory address accesses local variable and local function. It is fine design according to your preferance. I try to remove a pointer so I let local variable and local function as global to access to the memory directly without needing a...
32
363
by: mdh | last post by:
Hi all, When I try and initialize this static array, as in: void itoa_recursively(int n, char *s){ static char *p = s; it fails, yet this:
0
9923
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9767
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
11082
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10711
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
5774
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5967
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4592
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
4190
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3215
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.