I have the following code:
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#define initialSize 50
//Public GCC compiler-friendly macros
#define n argv[2]
using namespace std;
struct Point {
int x;
int y;
int z;
};
int smallest(Point* p, int n);
int size = 0, max_size = initialSize;
int *A = new int[max_size];
int main(int argc, char* argv[]) {
int test;
Point* p = new Point();
smallest(p, test);
return 0;
}
int smallest(Point *p, int n) {
return 0;
}
From my understanding, this should be valid syntax for C++. However I get the following compiling error:
test.cpp:32:20: error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive]
test.cpp:23:5: error: initializing argument 2 of ‘int smallest(Point*, int*)’ [-fpermissive]
I am using the command: g++ -std=c++11 test.cpp
EDIT: Added the entire source code instead of snippets. Tried on a different environment but encountered same compiling error.
See Question&Answers more detail:os