I have a basic main.cpp file and another file with a header (I will call it test.cpp and test.h).
From the main.cpp I would like to call a function in the test.cpp which returns a struct and it does not work. Here is what I have tried:
Main.cpp
#include <Test.h>
using namespace std;
struct Output
{
cv::Mat Tcw;
int state;
};
int main(int argc, char **argv)
{
struct Output tempOutput = foo(frame, timeStamps);
}
Test.h
#ifndef TEST_H
#define TEST_H
struct Output
{
cv::Mat Tcw;
int state;
};
struct Output foo();
#endif
Test.cpp
#include "Test.h"
struct Output foo()
{
cv::Mat mat;
int i = 3;
return {mat, i};
}
I have this error: error: conversion from ‘foo’ to non-scalar type ‘Output’ requested
Aucun commentaire:
Enregistrer un commentaire