473,406 Members | 2,387 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,406 software developers and data experts.

odd declaration error

i added a from called "Splash" to my project and am trying to get it to show
up on a formload event...but it gives a buildtime error on the line below

static Splash * frm = new Splash();

c:\Documents and Settings\User\Desktop\Final_Project\Final
Project\Final\Form1.h(1906): error C3845: 'Final::Form1::frm': only static
data members can be initialized inside a __gc class or value type
c:\Documents and Settings\User\Desktop\Final_Project\Final
Project\Final\Form1.h(1906): error C2039: 'Splash' : is not a member of
'Final'
c:\Documents and Settings\User\Desktop\Final_Project\Final
Project\Final\Form1.h(1906): error C2143: syntax error : missing ';' before
'*'
c:\Documents and Settings\User\Desktop\Final_Project\Final
Project\Final\Form1.h(1906): error C2039: 'Splash' : is not a member of
'Final'
c:\Documents and Settings\User\Desktop\Final_Project\Final
Project\Final\Form1.h(1906): error C2501: 'Final::Form1::frm' : missing
storage-class or type specifiers
what am i doing wrong?

--
-iwdu15
Jan 5 '06 #1
7 1413
iwdu15 wrote:
what am i doing wrong?


You're going to need to show a bit more code for someone to help you.

-cd


Jan 5 '06 #2
namespace Final
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

//
//
//
static Splash * frm = new Splash();
//
//
static PictureBox * arrBoard[,] = new PictureBox * [10, 10];
//
//
static Threading::Thread * FillThread = new Threading::Thread(new
ThreadStart(0, &Form1::Fill));
//
//
private: System::Void Form1_Load(System::Object * sender, System::EventArgs
* e)
{
frm->Show();

FillThread->Start();
}

private: System::Void Fill()
{

try
{

arrBoard[0,0] = this->pica0;
arrBoard[0,1] = this->pica1;
arrBoard[0,2] = this->pica2;
arrBoard[0,3] = this->pica3;
arrBoard[0,4] = this->pica4;
arrBoard[0,5] = this->pica5;
arrBoard[0,6] = this->pica6;
arrBoard[0,7] = this->pica7;
arrBoard[0,8] = this->pica8;
arrBoard[0,9] = this->pica9;
arrBoard[1,0] = this->picb0;
arrBoard[1,1] = this->picb1;
arrBoard[1,2] = this->picb2;
arrBoard[1,3] = this->picb3;
arrBoard[1,4] = this->picb4;
arrBoard[1,5] = this->picb5;
arrBoard[1,6] = this->picb6;
arrBoard[1,7] = this->picb7;
arrBoard[1,8] = this->picb8;
arrBoard[1,9] = this->picb9;
arrBoard[2,0] = this->picc0;
arrBoard[2,1] = this->picc1;
arrBoard[2,2] = this->picc2;
arrBoard[2,3] = this->picc3;
arrBoard[2,4] = this->picc4;
arrBoard[2,5] = this->picc5;
arrBoard[2,6] = this->picc6;
arrBoard[2,7] = this->picc7;
arrBoard[2,8] = this->picc8;
arrBoard[2,9] = this->picc9;
arrBoard[3,0] = this->picd0;
arrBoard[3,1] = this->picd1;
arrBoard[3,2] = this->picd2;
arrBoard[3,3] = this->picd3;
arrBoard[3,4] = this->picd4;
arrBoard[3,5] = this->picd5;
arrBoard[3,6] = this->picd6;
arrBoard[3,7] = this->picd7;
arrBoard[3,8] = this->picd8;
arrBoard[3,9] = this->picd9;
arrBoard[3,0] = this->pice0;
arrBoard[4,1] = this->pice1;
arrBoard[4,2] = this->pice2;
arrBoard[4,3] = this->pice3;
arrBoard[4,4] = this->pice4;
arrBoard[4,5] = this->pice5;
arrBoard[4,6] = this->pice6;
arrBoard[4,7] = this->pice7;
arrBoard[4,8] = this->pice8;
arrBoard[4,9] = this->pice9;
arrBoard[5,0] = this->picf0;
arrBoard[5,1] = this->picf1;
arrBoard[5,2] = this->picf2;
arrBoard[5,3] = this->picf3;
arrBoard[5,4] = this->picf4;
arrBoard[5,5] = this->picf5;
arrBoard[5,6] = this->picf6;
arrBoard[5,7] = this->picf7;
arrBoard[5,8] = this->picf8;
arrBoard[5,9] = this->picf9;
arrBoard[6,0] = this->picg0;
arrBoard[6,1] = this->picg1;
arrBoard[6,2] = this->picg2;
arrBoard[6,3] = this->picg3;
arrBoard[6,4] = this->picg4;
arrBoard[6,5] = this->picg5;
arrBoard[6,6] = this->picg6;
arrBoard[6,7] = this->picg7;
arrBoard[6,8] = this->picg8;
arrBoard[6,9] = this->picg9;
arrBoard[7,0] = this->pich0;
arrBoard[7,1] = this->pich1;
arrBoard[7,2] = this->pich2;
arrBoard[7,3] = this->pich3;
arrBoard[7,4] = this->pich4;
arrBoard[7,5] = this->pich5;
arrBoard[7,6] = this->pich6;
arrBoard[7,7] = this->pich7;
arrBoard[7,8] = this->pich8;
arrBoard[7,9] = this->pich9;
arrBoard[8,0] = this->pici0;
arrBoard[8,1] = this->pici1;
arrBoard[8,2] = this->pici2;
arrBoard[8,3] = this->pici3;
arrBoard[8,4] = this->pici4;
arrBoard[8,5] = this->pici5;
arrBoard[8,6] = this->pici6;
arrBoard[8,7] = this->pici7;
arrBoard[8,8] = this->pici8;
arrBoard[8,9] = this->pici9;
arrBoard[9,0] = this->picj0;
arrBoard[9,1] = this->picj1;
arrBoard[9,2] = this->picj2;
arrBoard[9,3] = this->picj3;
arrBoard[9,4] = this->picj4;
arrBoard[9,5] = this->picj5;
arrBoard[9,6] = this->picj6;
arrBoard[9,7] = this->picj7;
arrBoard[9,8] = this->picj8;
arrBoard[9,9] = this->picj9;

FillThread->Abort();

}

catch (Exception * ex)
{

}

}

};
}

thats my entire form1 code, with the windows code taken out because its all
picturebox names, nothing thatw ould interfere with a second form. i dont
understand becuase when i use the namespace of the project, Final, in the
declaration it says the form doesnt exist under it even though its there in
the intelisense....ex:

static Final::Splash * frm = new Final::Splash();

throws that buildtime error even though its in intelisense
--
-iwdu15
Jan 5 '06 #3
where and how is Splash declared?
different namespace perhaps?

kind regards,
Bruno.
"iwdu15" <iw****@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
namespace Final
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

//
//
//
static Splash * frm = new Splash();
//
//
static PictureBox * arrBoard[,] = new PictureBox * [10, 10];
//
//
static Threading::Thread * FillThread = new Threading::Thread(new
ThreadStart(0, &Form1::Fill));
//
//
private: System::Void Form1_Load(System::Object * sender,
System::EventArgs
* e)
{
frm->Show();

FillThread->Start();
}

private: System::Void Fill()
{

try
{

arrBoard[0,0] = this->pica0;
arrBoard[0,1] = this->pica1;
arrBoard[0,2] = this->pica2;
arrBoard[0,3] = this->pica3;
arrBoard[0,4] = this->pica4;
arrBoard[0,5] = this->pica5;
arrBoard[0,6] = this->pica6;
arrBoard[0,7] = this->pica7;
arrBoard[0,8] = this->pica8;
arrBoard[0,9] = this->pica9;
arrBoard[1,0] = this->picb0;
arrBoard[1,1] = this->picb1;
arrBoard[1,2] = this->picb2;
arrBoard[1,3] = this->picb3;
arrBoard[1,4] = this->picb4;
arrBoard[1,5] = this->picb5;
arrBoard[1,6] = this->picb6;
arrBoard[1,7] = this->picb7;
arrBoard[1,8] = this->picb8;
arrBoard[1,9] = this->picb9;
arrBoard[2,0] = this->picc0;
arrBoard[2,1] = this->picc1;
arrBoard[2,2] = this->picc2;
arrBoard[2,3] = this->picc3;
arrBoard[2,4] = this->picc4;
arrBoard[2,5] = this->picc5;
arrBoard[2,6] = this->picc6;
arrBoard[2,7] = this->picc7;
arrBoard[2,8] = this->picc8;
arrBoard[2,9] = this->picc9;
arrBoard[3,0] = this->picd0;
arrBoard[3,1] = this->picd1;
arrBoard[3,2] = this->picd2;
arrBoard[3,3] = this->picd3;
arrBoard[3,4] = this->picd4;
arrBoard[3,5] = this->picd5;
arrBoard[3,6] = this->picd6;
arrBoard[3,7] = this->picd7;
arrBoard[3,8] = this->picd8;
arrBoard[3,9] = this->picd9;
arrBoard[3,0] = this->pice0;
arrBoard[4,1] = this->pice1;
arrBoard[4,2] = this->pice2;
arrBoard[4,3] = this->pice3;
arrBoard[4,4] = this->pice4;
arrBoard[4,5] = this->pice5;
arrBoard[4,6] = this->pice6;
arrBoard[4,7] = this->pice7;
arrBoard[4,8] = this->pice8;
arrBoard[4,9] = this->pice9;
arrBoard[5,0] = this->picf0;
arrBoard[5,1] = this->picf1;
arrBoard[5,2] = this->picf2;
arrBoard[5,3] = this->picf3;
arrBoard[5,4] = this->picf4;
arrBoard[5,5] = this->picf5;
arrBoard[5,6] = this->picf6;
arrBoard[5,7] = this->picf7;
arrBoard[5,8] = this->picf8;
arrBoard[5,9] = this->picf9;
arrBoard[6,0] = this->picg0;
arrBoard[6,1] = this->picg1;
arrBoard[6,2] = this->picg2;
arrBoard[6,3] = this->picg3;
arrBoard[6,4] = this->picg4;
arrBoard[6,5] = this->picg5;
arrBoard[6,6] = this->picg6;
arrBoard[6,7] = this->picg7;
arrBoard[6,8] = this->picg8;
arrBoard[6,9] = this->picg9;
arrBoard[7,0] = this->pich0;
arrBoard[7,1] = this->pich1;
arrBoard[7,2] = this->pich2;
arrBoard[7,3] = this->pich3;
arrBoard[7,4] = this->pich4;
arrBoard[7,5] = this->pich5;
arrBoard[7,6] = this->pich6;
arrBoard[7,7] = this->pich7;
arrBoard[7,8] = this->pich8;
arrBoard[7,9] = this->pich9;
arrBoard[8,0] = this->pici0;
arrBoard[8,1] = this->pici1;
arrBoard[8,2] = this->pici2;
arrBoard[8,3] = this->pici3;
arrBoard[8,4] = this->pici4;
arrBoard[8,5] = this->pici5;
arrBoard[8,6] = this->pici6;
arrBoard[8,7] = this->pici7;
arrBoard[8,8] = this->pici8;
arrBoard[8,9] = this->pici9;
arrBoard[9,0] = this->picj0;
arrBoard[9,1] = this->picj1;
arrBoard[9,2] = this->picj2;
arrBoard[9,3] = this->picj3;
arrBoard[9,4] = this->picj4;
arrBoard[9,5] = this->picj5;
arrBoard[9,6] = this->picj6;
arrBoard[9,7] = this->picj7;
arrBoard[9,8] = this->picj8;
arrBoard[9,9] = this->picj9;

FillThread->Abort();

}

catch (Exception * ex)
{

}

}

};
}

thats my entire form1 code, with the windows code taken out because its
all
picturebox names, nothing thatw ould interfere with a second form. i dont
understand becuase when i use the namespace of the project, Final, in the
declaration it says the form doesnt exist under it even though its there
in
the intelisense....ex:

static Final::Splash * frm = new Final::Splash();

throws that buildtime error even though its in intelisense
--
-iwdu15

Jan 5 '06 #4
#pragma once

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace Final
{
/// <summary>
/// Summary for Splash
///
/// WARNING: If you change the name of this class, you will need to change
the
/// 'Resource File Name' property for the managed resource
compiler tool
/// associated with all .resx files this class depends on.
Otherwise,
/// the designers will not be able to interact properly with
localized
/// resources associated with this form.
/// </summary>
public __gc class Splash : public System::Windows::Forms::Form
{
public:
Splash(void)
{
InitializeComponent();
}

protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::Timer * tmrrnd;
private: Control_Trial::PercentProgressBar * prgLoad;

private: System::ComponentModel::IContainer * components;

private:
/// <summary>
/// Required designer variable.
/// </summary>
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->components = new System::ComponentModel::Container();
this->tmrrnd = new System::Windows::Forms::Timer(this->components);
this->prgLoad = new Control_Trial::PercentProgressBar();
this->SuspendLayout();
//
// prgLoad
//
this->prgLoad->Location = System::Drawing::Point(40, 384);
this->prgLoad->Name = S"prgLoad";
this->prgLoad->PercentFontColor = System::Drawing::Color::Red;
this->prgLoad->PropBarColor1 =
System::Drawing::SystemColors::InactiveCaption;
this->prgLoad->PropBarColor2 = System::Drawing::SystemColors::Highlight;
this->prgLoad->Size = System::Drawing::Size(568, 32);
this->prgLoad->TabIndex = 0;
this->prgLoad->Text = S"percentProgressBar1";
//
// Splash
//
this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
this->ClientSize = System::Drawing::Size(656, 486);
this->ControlBox = false;
this->Controls->Add(this->prgLoad);
this->Name = S"Splash";
this->ShowInTaskbar = false;
this->StartPosition =
System::Windows::Forms::FormStartPosition::CenterS creen;
this->ResumeLayout(false);

}

//
/*
Jonathan Miller
Period 3
1-2-06
Splash Screen
Final Project
*/

static bool load = true;

private: System::Void SplashScreen_Load(System::Object * sender,
System::EventArgs * e)
{

this->tmrrnd->Start();

}

private: System::Void tmrrnd_Tick(System::Object * sender,
System::EventArgs * e)
{

Random * rnd = new Random;

int rand = rnd->Next(9),
val = this->prgLoad->Value,
max = this->prgLoad->Maximum;
if (val + rand < max)
{

this->prgLoad->Value += rand;
this->prgLoad->Update();

}
else
{

this->prgLoad->Value += (this->prgLoad->Maximum - this->prgLoad->Value);
this->prgLoad->Update();

}

}
};
}

thats the splash code....same namespace and everything....and im trying to
get a declaraton...like in vb id do this

''Global Var
Private frm as new Splash

i dont know how to do that in C++
--
-iwdu15
Jan 5 '06 #5
maybe a stupid question, but did you include Splash.h before Form1.h in the
CPP file in which Form1.h is included?
(that would be Form1.cpp??)
because otherwise the compiler will have no declaration for Splash while
trying to parse Form1.h

also, the line
static Splash * frm = new Splash();
seems to be placed outside a function scope. i think this is not allowed.
you try to instantiate a Splash screen, but you don't do it from inside a
function.

if that doesn't help you, could you post your project (or a stripped down
version with the same error) so that i can investigate in more detail?

also, your

kind regards,
Bruno.
"iwdu15" <jmmgoalsteratyahoodotcom> wrote in message
news:2F**********************************@microsof t.com...
#pragma once

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace Final
{
/// <summary>
/// Summary for Splash
///
/// WARNING: If you change the name of this class, you will need to change
the
/// 'Resource File Name' property for the managed resource
compiler tool
/// associated with all .resx files this class depends on.
Otherwise,
/// the designers will not be able to interact properly with
localized
/// resources associated with this form.
/// </summary>
public __gc class Splash : public System::Windows::Forms::Form
{
public:
Splash(void)
{
InitializeComponent();
}

protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::Timer * tmrrnd;
private: Control_Trial::PercentProgressBar * prgLoad;

private: System::ComponentModel::IContainer * components;

private:
/// <summary>
/// Required designer variable.
/// </summary>
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->components = new System::ComponentModel::Container();
this->tmrrnd = new System::Windows::Forms::Timer(this->components);
this->prgLoad = new Control_Trial::PercentProgressBar();
this->SuspendLayout();
//
// prgLoad
//
this->prgLoad->Location = System::Drawing::Point(40, 384);
this->prgLoad->Name = S"prgLoad";
this->prgLoad->PercentFontColor = System::Drawing::Color::Red;
this->prgLoad->PropBarColor1 =
System::Drawing::SystemColors::InactiveCaption;
this->prgLoad->PropBarColor2 = System::Drawing::SystemColors::Highlight;
this->prgLoad->Size = System::Drawing::Size(568, 32);
this->prgLoad->TabIndex = 0;
this->prgLoad->Text = S"percentProgressBar1";
//
// Splash
//
this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
this->ClientSize = System::Drawing::Size(656, 486);
this->ControlBox = false;
this->Controls->Add(this->prgLoad);
this->Name = S"Splash";
this->ShowInTaskbar = false;
this->StartPosition =
System::Windows::Forms::FormStartPosition::CenterS creen;
this->ResumeLayout(false);

}

//
/*
Jonathan Miller
Period 3
1-2-06
Splash Screen
Final Project
*/

static bool load = true;

private: System::Void SplashScreen_Load(System::Object * sender,
System::EventArgs * e)
{

this->tmrrnd->Start();

}

private: System::Void tmrrnd_Tick(System::Object * sender,
System::EventArgs * e)
{

Random * rnd = new Random;

int rand = rnd->Next(9),
val = this->prgLoad->Value,
max = this->prgLoad->Maximum;
if (val + rand < max)
{

this->prgLoad->Value += rand;
this->prgLoad->Update();

}
else
{

this->prgLoad->Value += (this->prgLoad->Maximum - this->prgLoad->Value);
this->prgLoad->Update();

}

}
};
}

thats the splash code....same namespace and everything....and im trying to
get a declaraton...like in vb id do this

''Global Var
Private frm as new Splash

i dont know how to do that in C++
--
-iwdu15

Jan 5 '06 #6
i tried to send you an email but it said your mailbox wasnt available....i
added "splash" after the original form came up...and making it a local
variable in a method doesnt work either, and they are both part of the same
namespace
--
-iwdu15

Jan 5 '06 #7
iwdu15 wrote:

thats my entire form1 code, with the windows code taken out because
its all picturebox names, nothing thatw ould interfere with a second
form. i dont understand becuase when i use the namespace of the
project, Final, in the declaration it says the form doesnt exist
under it even though its there in the intelisense....ex:

static Final::Splash * frm = new Final::Splash();

throws that buildtime error even though its in intelisense


Intellisense will see things that the compiler can't see because it parses
all the files in your project, even if they're not included in the file
you're compiling.

Here's a prototypical arrangement with a couple of forms, one of which
references the other:

<code>
// Splash.h
namespace app
{
__gc class Splash : public System::Windows::Forms::Form
{
// TODO: add definition of Splash
};
}

// MainForm.h
#include "splash.h"

namespace app
{
__gc class MainForm : public System::Windows::Forms::Form
{
static Splash* m_splash = new Splash();

// TODO: add definition of MainForm
};
}

// FormsApp.cpp
#using <mscorlib.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>

#include "mainform.h"

int main()
{
using namespace app;

MainForm* pm = new MainForm();
}

</code>

Note that MainFrom.h #includes Splash.h so the definition of Splash is
visible to the compiler. Note also that the definition of m_splash is a
static member variable, not a namespace-scoped variable. You can't declare
a namespace-scoped variable of type pointer-to-gc-class.

I hope that helps get you over this hurdle.

-cd

Jan 6 '06 #8

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

Similar topics

83
by: Alexander Zatvornitskiy | last post by:
Hello All! I'am novice in python, and I find one very bad thing (from my point of view) in language. There is no keyword or syntax to declare variable, like 'var' in Pascal, or special syntax in...
3
by: Michael Sgier | last post by:
Hello with the original code below I get the error: "forward declaration of `struct CPlayer'" class CPlayer; // what does this do? Instantiate the class CPlayer? // what's a forward...
1
by: HappyHippy | last post by:
Hi, I have a question about forward declaration of classes. First of all, a simple working example, which compiles and works with no problems. ///file class_a.h:/ #ifndef __CLASS_A_H__...
6
by: WaterWalk | last post by:
I find friend declaration just very tricky. I tried the following examples on both MingW(gcc 3.4.2) and VC++ 2005. The results are surprising. Example1: namespace ns1 { class Test { friend...
6
by: samsneelam | last post by:
Hi.. This is samuel, while doing a program, i encountered this problem.. Let me give you clarity regarding my prob.. I am having two files .. one is mpcplib.h it contains the follwing...
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...
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
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
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...
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,...

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.