[ create a new paste ] login | about

Link: http://codepad.org/v7cVm4ZW    [ raw code | output | fork ]

C++, pasted on Sep 27:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <cstdarg>

using namespace std;

int g_myInt = 5;
int& getIntReference() { return g_myInt; }

int myVarArgFunction( int a, ...) {
  va_list arguments;
  va_start(arguments, a); 
  
  return a + va_arg(arguments, int&);
}

int main() {
  cout<<myVarArgFunction( 10, getIntReference() )<<endl;
  return 0;
}


Output:
1
2
3
cc1plus: warnings being treated as errors
In function 'int myVarArgFunction(int, ...)':
Line 13: warning: cannot receive objects of non-POD type 'int&' through '...'; call will abort at runtime


Create a new paste based on this one


Comments: