Reputation: 137
I defined my own Enum type as
enum Norm {norm1, norm2};
Now, in my main()
, I am clustering an image using different type of norms.
The prototype of that being:
int extraction(char* cloudfile, float& maximumRadius, Norm norm);
And the part within main()
where that function is called, being inside a getops
switch, is:
extraction(argv[2], maximumRadius, norm2);
meaningful?
I tried to run several times, but gdb tells me there is a segmentation fault that I cannot find.
Hence my current question :
Can an Enum type be used as a parameter of a function? Or must I resort to predefined types?
Upvotes: 0
Views: 946
Reputation: 2355
Enum types are just plain integers mapped to names. It is absolutely alright to use them as function parameters.
There is no possible way that this enum will cause the segmentation fault. Segmentation fault is caused by trying to access memory that is not meant for your task. This is mostly caused by exceeding the allocated memory buffer or inappropriate pointer assignment.
Upvotes: 0
Reputation: 1237
Yes it's absolutely possible to use an enum as function parameter. The segmentation fault came from another place.
Upvotes: 5