calling a fiction though a variable

I am trying to call a function though a variable
Please tell me what I am doing wrong

The error

|error: no match for 'operator=' (operand types are 'std::string {aka std::basic_string<char>}' and 'void')|

|warning: statement has no effect [-Wunused-value]|
||=== Build failed: 1 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|

#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <stdio.h>
#include <windows.h>
using namespace std;

class Createc{
string function_call;

void Create()
function_call = thefuction();

void thefuction()
cout << "plz help" << endl;

int main()
Createc create;
Your variable 'function_call' (terrible name by the way) is a string, your function "thefunction()" returns void (aka nothing) so there is nothing to assign to 'function_call'.
I changed it to int and that worked!
Thank you

by the way the function_call is a terrible name but this was an example and I wanted it to be descriptive.
It would compile if that's what you mean. I wouldn't say it "works" quite yet.

I only commented on the variable name because, to me, it makes it seem like it would be a Lambda or a std::function.
Topic archived. No new replies allowed.