Used but never defined

Apr 28, 2014 at 3:15pm
Can anyone explain why I'm getting this error.

g++ -std=c++11 -Wall -o "Test7" "Test7.cpp" (in directory: /home/aceix/Documents/C++ Codes)
Test7.cpp:10:3: error: ‘constexpr const<lambda()> Test::func’, declared using local type ‘const<lambda()>’, is used but never defined [-fpermissive]
Compilation failed.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>

using namespace std;

class Test {
	public:
	static constexpr auto func=[]()->int{
			cout<<"Lambda has been assigned to auto";
			return 0;
		};
	Test() {
		
	}
};

int main() {
	Test obj;
	
	obj.func();
	
	return 0;
}
Last edited on Apr 28, 2014 at 3:34pm
Apr 28, 2014 at 3:25pm
Lambda has been assigned to auto in constructor


Doesn't look to me like you're doing anything in the constructor?
Apr 28, 2014 at 3:33pm
Yes I'm not intending to do stuff in the constructor. I'm just trying to see if auto variables can be assigned lambdas.

EDIT: @mutexe: yeah it was first in the ctor.

Aceix.
Last edited on Apr 28, 2014 at 3:35pm
Topic archived. No new replies allowed.