I am learning C++ using the resources listed here. In particular, i read that we can use the auto type specifier as the return type of a function. So to get clarity over the concept, i tried the following example:
header.h
#pragma once
struct S
{
auto f();
};
source.cpp
#include "header.h"
auto S::f()
{
return 4;
}
main.cpp
#include <iostream>
#include "header.h"
int main()
{
S s;
s.f();
return 0;
}
But this gives me error saying:
main.cpp:7:9: error: use of ‘auto S::f()’ before deduction of ‘auto’
7 | s.f();
| ^
My question is why am i getting this error and how to solve this.