is possible create a any type variable(1 variable that accept any type of values)?

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

and see my post #15 with the solution using variadic templates. As gcc 4.8.1 supports variadic templates, this code should compile and give you the write function you originally wanted without using the variant class - which I suspect is going to give more trouble than it's worth.

Re: is possible create a any type variable(1 variable that accept any type of values)

Because as part of your variadic template read, you have the function

Code:

void read() {}

so you cannot have another function with the definition void read(void) - which is the same as void read()!

However, for your ReadConsole read function, it takes no arguments and returns void - so what happens to what it reads and what's its purpose? I would suggest changing its function name to something like readcon(..). Also, why are you closing the handle for standard input?

All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Re: is possible create a any type variable(1 variable that accept any type of values)

Originally Posted by 2kaud

Because as part of your variadic template read, you have the function

Code:

void read() {}

so you cannot have another function with the definition void read(void) - which is the same as void read()!

However, for your ReadConsole read function, it takes no arguments and returns void - so what happens to what it reads and what's its purpose? I would suggest changing its function name to something like readcon(..). Also, why are you closing the handle for standard input?

that function is only for wait the user click in enter for continue\exit

and seems to work normaly.... sometimes my brain works more hehehehe
but tell me what you think
heres how use them:

Code:

Console a; int c=10;
a.read(c) ;
a.write(c);
a.read();

let me ask you 1 last thing about header files. how can i test if the header file was called?
(for don't give about the function be double declared(or something like it))
thanks for all my friend.. thanks to both
(i'm trying rate you, both, but isn't easy)

Re: is possible create a any type variable(1 variable that accept any type of values)

let me ask you 1 last thing about header files. how can i test if the header file was called?

??? You don't call a header file. You include a header file to provide the definitions for class/functions etc. If your code uses a class or function defined in a header and the header hasn't been included then the compiler will soon complain.

If you mean how do you prevent the header file from being included more than once, then there are two ways

The simplest is to have the statement

Code:

#pragma once

as the first line of the header file. However, not all compilers recognise this. The 'standard' way is to use a 'guard define' like this

Re: is possible create a any type variable(1 variable that accept any type of values)

Originally Posted by 2kaud

??? You don't call a header file. You include a header file to provide the definitions for class/functions etc. If your code uses a class or function defined in a header and the header hasn't been included then the compiler will soon complain.

If you mean how do you prevent the header file from being included more than once, then there are two ways

The simplest is to have the statement

Code:

#pragma once

as the first line of the header file. However, not all compilers recognise this. The 'standard' way is to use a 'guard define' like this

Re: is possible create a any type variable(1 variable that accept any type of values)

Originally Posted by Cambalinho

why use a namespace, if is only use 1 class?
thanks for all

It is 1 class now, but what about tomorrow, next month, next year? You don't know the future.

What if you write new code, and your name clashes with an existing name from another class that may not be yours? For example, what if you created a class called "list", or "string" or "map", etc. and you now #include a standard header that just happens to have classes with the same name?

Re: is possible create a any type variable(1 variable that accept any type of values)

seems that both functions are called
but i simply create a boolean variable and now seems to work....
and seems to work normaly.... sometimes my brain works more
but tell me what you think

I would advise caution about mixing c++ io streaming (using cin, cout etc) with the low-level console functions (ReadConsole etc) - especially on input as 'strange' results can happen if the streaming io buffers are not empty before using the ReadConsole/WriteConsole group of functions.

All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Re: is possible create a any type variable(1 variable that accept any type of values)

Originally Posted by 2kaud

I would advise caution about mixing c++ io streaming (using cin, cout etc) with the low-level console functions (ReadConsole etc) - especially on input as 'strange' results can happen if the streaming io buffers are not empty before using the ReadConsole/WriteConsole group of functions.

so what is the best way for clean the streaming io buffers?
(maybe that's why the getch(), sometimes, is ignored)