[prev in list] [next in list] [prev in thread] [next in thread]
List: hpux-cxx-dev
Subject: RE: CXX-DEV: Template instantiation with non-public enum value.
From: hefin.jones () vf ! vodafone ! co ! uk
Date: 1999-05-25 12:58:05
[Download RAW message or body]
> On A.01.18 (and all other versions), both enum and static const cases
> fail.
Really? The following works fine for me:
-- Number.H --
template< int num >
class Number {
public:
Number() { };
};
-- Clinet.H --
class Client {
public:
Client();
private:
static const int value = 10;
};
-- Client.C --
#include <Client.H>
#include <Number.H>
const int Client::value;
Client::Client() {
Number< Client::value > num;
}
--
However, if I change value to an enum, e.g.:
-- Clinet.H --
class Client {
public:
Client();
private:
enum { value = 10 }
};
-- Client.C --
#include <Client.H>
#include <Number.H>
Client::Client() {
Number< Client::value > num;
}
--
I get:
Error 558: "Client.C", line 9 # Cannot access private member
"Client::{unnamed.enum.#1} value".
Number< Client::value > num;
^^^^^^^^^^^^^
> A workaround would be to create a local constant expression
> in Client().
I don't need to do this as either a private static const int, or a public
enum work just fine. A private enum, however, does not. I was curious at to
why.
Thank you.
--
Hefin Jones
Software Developer
Vodafone Ltd. Tel: +441635677277
_________________________________________________________________
To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
with the message UNSUBSCRIBE cxx-dev
_________________________________________________________________
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic