Is there a way to initialize an member array of user defined objects that is
declared static const?
For example:
const vec3f I(1,0,0);
const vec3f j(0,1,0);
class corner_functor
{
public:
corner_functor( );
~corner_functor ();
static const Vec3f dir[5] = {-I, J, I, -J, -I};//This doesn't work
private:
int index;
};
I also tried some variations of this:
const SbVec3f* corner_functor: :dir =
{
-I, J, I, -J, -I
};
--
STH
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org 1 2546
"Steven T. Hatton" <su******@setid ava.kushan.aa> wrote in message Is there a way to initialize an member array of user defined objects that
is declared static const?
For example:
const vec3f I(1,0,0); const vec3f j(0,1,0);
class corner_functor { public: corner_functor( );
~corner_functor (); static const Vec3f dir[5] = {-I, J, I, -J, -I};//This doesn't work private: int index;
};
Only const int, long, short, char, bool, and integral constants in general
can be initialized in the class. Try,
class corner_functor
{
...
static const Vec3f dir[5];
};
const Vec3f corner_functor: :dir[5] = {-I, J, I, -J, -I};
The above line should occur in the cpp file. You can also define I and J in
the same cpp file.
Note that the following is undefined in ANSI C++
// header.h
extern const Vec3f I;
extern const Vec3f J;
// functor.h
defines class corner_functor;
// functor.cpp
#include "header.h"
const Vec3f corner_functor: :dir[5] = {-I, J, I, -J, -I}; This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rahul Joshi |
last post by:
Hi,
I want to create a static array whose size is also a const
member of the class. Something like:
// A.h
class A {
private:
static int size = 0;
static int array;
|
by: Neno |
last post by:
Hi,
I have a linkage error that has something to do with the use of a static
member array and I can't understand how to solve the problem. Can someone
help me please?
In detail:
A class Month (it is just an unsafe and useless example) has protected
constructors so that Month objects can be obtained only through a static
member function named getMonth.
Month class has a private static array named months made of 12 pointers to
Month...
|
by: Drew McCormack |
last post by:
I am getting an error in g++ 4.0.0 that I did not get in g++ 3.4. I
have a header with the following const variables with namespace scope:
namespace Periphery {
extern const double ProtonMassInAtomicUnits = 1836.152755656068;
}
I try to use these in another header to initialize static const member
|
by: Bart Goeman |
last post by:
Hi,
I have a question about how to put redundant information in data
structures, initialized at compile time. This is often necessary
for performance reasons and can't be done at run time (data
structures are read only)
Ideally one should be able to put the redundant
information there automatically so no mistakes are possible, but in a lot
of case I see no way how to do it.
|
by: Mark Dunmill |
last post by:
I can't create a Constant/Read-only array field in managed C++ classes -
doesn't allow the keyword const pointer to const object on array fields in
managed C++ classes. e.g. Want to define a read/only field for an empty array
(so all the empty arrays of the given type can use the same object) however
because the pointer in the field cannot be marked as constant then it is
possible that any external party can alter this pointer to reference...
| |
by: utab |
last post by:
Dear all, I am confused at some point on the initialization of static
map member of a class. The class I have designed id something like
this.
class Class_name{
public:
private:
|
by: jayharris |
last post by:
I'm having a ton of trouble initializing a multi-dimensional array
inside a constructor, largely because I don't know the size of the
array until runtime. I have a class that looks like this:
class MyClass
{
public:
const int size;
MyClass( const int );
};
|
by: alacrite |
last post by:
If I have this situation
class X
{
Z z;
Y y;
};
Class X has two objects of type Z and Y. How do I initialize z and y
with non default constructors?
|
by: akomiakov |
last post by:
Is there a technical reason why one can't initialize a cost static non-
integral data member in a class?
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |