Board index » cppbuilder » Struct

Struct


2006-04-13 10:43:25 PM
cppbuilder71
Hi,
i wrote down the code below:
struct MyValues
{
int value1;
int value2;
int value3;
float value4;
float value5;
float value6;
float value7;
float value8;
String valu9;
};
vector<MyValues>values;
and i got this error : template argument can not have static or local
linkage. How can i fix this?
thanks
 
 

Re:Struct

"Cenk" < XXXX@XXXXX.COM >writes:
Quote
Hi,

i wrote down the code below:

struct MyValues
{
int value1;
int value2;
int value3;
float value4;
float value5;
float value6;
float value7;
float value8;
String valu9;
};
vector<MyValues>values;

and i got this error : template argument can not have static or local
linkage. How can i fix this?
Your code is rather incomplete, as it won't compile. You omit a lot
of important things. When you post a problem, please make sure it's a
COMPLETE sample of what the problem is! Here is a complete program
and it works:
#include <vector>
#include <string>
struct MyValues
{
int value1;
int value2;
int value3;
float value4;
float value5;
float value6;
float value7;
float value8;
std::string valu9;
};
std::vector<MyValues>values;
int main()
{
}
I have to guess (and don't like having to do that!) that you declared
MyValues inside a function, which gives it "local" (internal)
linkage. It's *really* important to show the environment in which
your code is written.
--
Chris (TeamB);
 

Re:Struct

"Cenk" < XXXX@XXXXX.COM >wrote:
Quote
Hi,

i wrote down the code below:

struct MyValues
{
[snip]
};
vector<MyValues>values;

and i got this error : template argument can not have static
or local linkage. How can i fix this?
Supposedly you have something like this:
void foo()
{
struct MyValues...
vector<MyValues>values;
}
and should make it thus:
struct MyValues...
void foo()
{
vector<MyValues>values;
}
The struct defines a data structure which you want to use in
your vector. As a vector is a template, that struct definition
must not be local to your function/class.
 

{smallsort}

Re:Struct

Chris Uzdavinis (TeamB) < XXXX@XXXXX.COM >writes:
Quote
I have to guess (and don't like having to do that!) that you declared
MyValues inside a function, which gives it "local" (internal)
linkage. It's *really* important to show the environment in which
your code is written.
<picking nits again, I know>
Local variables have *no* linkage. Static variables with namespace
scope have internal linkage.
 

Re:Struct

XXXX@XXXXX.COM (Thomas Maeder [TeamB]) writes:
Quote
Chris Uzdavinis (TeamB) < XXXX@XXXXX.COM >writes:

>I have to guess (and don't like having to do that!) that you declared
>MyValues inside a function, which gives it "local" (internal)
>linkage. It's *really* important to show the environment in which
>your code is written.

<picking nits again, I know>

Local variables have *no* linkage. Static variables with namespace
scope have internal linkage.
One of these days your point will be driven home. (Arrrgh.)
Thanks.
--
Chris (TeamB);