Espaços nominais
Variantes
Acções

va_start

Da cppreference.com
< cpp‎ | utility‎ | variadic

 
 
Biblioteca de utilitários
Digite apoio (basic types, RTTI, type traits)
Gerenciamento de memória dinâmica
De tratamento de erros
Utilidades do programa
Variadic funções
Data e hora
Objetos de função
(C++11)
Os operadores relacionais
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Pares e tuplas
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
Troque, avançar e avançar
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
 
 
Definido no cabeçalho <cstdarg>
void va_start(va_list ap, parm_n);
A macro va_start permite o acesso aos argumentos variável após o argumento nomeado parm_n.
Original:
The va_start macro enables access to the variable arguments following the named argument parm_n.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
va_start deve ser chamado com uma instância de um objeto válido va_list ap antes de todas as chamadas para va_arg.
Original:
va_start should be invoked with an instance to a valid va_list object ap before any calls to va_arg.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Índice

[editar] Parâmetros

ap -
uma instância do tipo va_list
Original:
an instance of the va_list type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
parm_n -
o parâmetro denominado precede o primeiro parâmetro variável
Original:
the named parameter preceding the first variable parameter
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Expandiu valor

(Nenhum)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Exemplo

#include <iostream>
#include <cstdarg>
 
int add_nums(int count, ...) 
{
    int result = 0;
    va_list args;
    va_start(args, count);
    for (int i = 0; i < count; ++i) {
        result += va_arg(args, int);
    }
    return result;
}
 
int main() 
{
    std::cout << add_nums(4, 25, 25, 50, 50) << '\n';
}

Saída:

150

[editar] Veja também

acessa o argumento da função próximo aridade
Original:
accesses the next variadic function argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função macro) [edit]
termina travessia dos argumentos da função variádicos
Original:
ends traversal of the variadic function arguments
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função macro) [edit]