Initialization: const type x((function(A)) ? B : C);



 DEVELOP > c-Plus-Plus > Initialization: const type x((function(A)) ? B : C);

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Charlie Zender"
Date: 31 Jan 2004 11:08:40 AM
Object: Initialization: const type x((function(A)) ? B : C);
Hi,
I want to initialize a const with the result of a function and an
if test. Is this legal?
main(){
const std::string nvr_USER((std::getenv("USER")) ? std::getenv("USER") :
"");
}
Thanks,
Charlie
--
Charlie Zender, surname@uci.edu, (949) 824-2987, Department of Earth
System Science, University of California, Irvine CA 92697-3100
.

User: "Victor Bazarov"

Title: Re: Initialization: const type x((function(A)) ? B : C); 31 Jan 2004 12:23:03 PM
"Charlie Zender" <zender@uci.edu> wrote...

I want to initialize a const with the result of a function and an
if test. Is this legal?

Yes. Your const is not going to be compile-time const, that's all.


main(){

int main(){

const std::string nvr_USER((std::getenv("USER")) ? std::getenv("USER") :
"");

Extra paren...

}

.


  Page 1 of 1

1

 


Related Articles
"const int" as function parameter type
const type qualifier after function name
type of pointer to member function
Re: Enable functions in the derived class with the same function name but different return type?
Function template type inference doesn't work with inheritance?
How to make a Function with Variable Argument List (type unknown)
Re: Enable functions in the derived class with the same function name but different return type?
virtual table, type_info node, type_info function
Can I use typedef to define types used in the return type in template function?
Is this a legal function type?
pointer-to-member-function return type
Re: Enable functions in the derived class with the same function name but different return type?
Pointer to member function - type
Forcing all function template parameters to deduce the same type
Conceptual function type problem
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER