the code TextureMeta(string tex_, int args_, const char* …) { va_list vl; va_start(vl, args_); for (int i = 0; i < args_; i++) { string img_(va_arg(vl, char*)); cout << img_ << endl; images.push_back(img_); } va_end(vl); } on MSVC it works fine but on MacOS the generated application got segmentation error, i can see the code ..
Category : arguments
How to create a function that can pass a variable number of arguments that are pointers to objects of the same class? It is desirable that it would be impossible to pass other data types. (Its quantity will be passed too) There are no problems when working with standard types of variables, but no examples ..
I am trying to use a python program which is in executable form inside another program written in C++. What I am trying to do is passing arguments from c++ and get return of the exe inside my c++ program. I’ve figured out how to pass argument but I am looking for a way to ..
Doing a beginner coding assignment for my c++ course. I’m fairly new and pointers has me stumbling a bit. What I’m trying to do with my code is have the function intSwapper return an array using a pointer. Since arrays can’t be normally returned, I have to use a pointer but I’m still trying to ..
Is there a way in C++ to pass arguments by name like in python? For example I have a function: void foo(int a, int b = 1, int c = 3, int d = 5); Can I somehow call it like: foo(5 /* a */, c = 5, d = 8); Or foo(5, /* a ..
so I have a template function: int someFunc(int num) { int a = num / 2; int b = num + 10; return a + num / b + b; } template<typename Type, typename Function> Type test() { Function func = (Function)&someFunc; return func(); } In the function test I now want to call other ..
Problem: I have a C++11 method (CImg class) that takes in input an unsigned char[3] array to specify the color. I’m compiling with a mingw compiler and -std=gnu++11 option. For reference this is the method I need to call: template<typename tc> CImg<T>& draw_line(int x0, int y0, int x1, int y1, const tc *const color, const ..
I have an array initialised like the following: int example[5][5]; And a function: void example_function(int inArray, int z){ cout << "example text = " << inArray[z][z] << endl; } And I am calling it into the function like this: example_function(example, 4); As you can see, I have the parameter for the function as integer when ..
I’m developing a networking library in C++. I have a method that sends a network packet. Signature: void Send(PacketId packet_id, const UserPacket& user_packet, const std::shared_ptr<RemoteSystem>& remote_system, bool broadcast, std::function<void(Packet* p)>&& response_callback, uint32_t response_timeout, std::function<void()>&& response_timeout_callback, uint32_t response_to_packet); Arguments: packet_id – Packet id user_packet – User packet data remote_system – remote system to send a packet ..
I wish to be able to manipulate function arguments by the order in which they are given. So, void sum(int a, int b, int c) std::cout<< arguments[0]+arguments[1]; sum(1,1,4); should print 2. This feature is in Java, I found out about it here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments. I need it to implement a numerical scheme. I’d create a function ..
Recent Comments