वेक्टर के उपयोग करते हुए मैं निम्नलिखित कोड में परेशानी आ रही है और यह पता लगाने की क्या गलतC++
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
double distance(int a, int b)
{
return fabs(a-b);
}
int main()
{
vector<int> age;
age.push_back(10);
age.push_back(15);
cout<<distance(age[0],age[1]);
return 0;
}
त्रुटि है नहीं कर पा रहे समारोह दूरी की फोन करने में निहित है।
/usr/include/c++/4.6/bits/stl_iterator_base_types.h: In instantiation of ‘std::iterator_traits<int>’:
test.cpp:18:30: instantiated from here
/usr/include/c++/4.6/bits/stl_iterator_base_types.h:166:53: error: ‘int’ is not a class, struct, or union type
/usr/include/c++/4.6/bits/stl_iterator_base_types.h:167:53: error: ‘int’ is not a class, struct, or union type
/usr/include/c++/4.6/bits/stl_iterator_base_types.h:168:53: error: ‘int’ is not a class, struct, or union type
/usr/include/c++/4.6/bits/stl_iterator_base_types.h:169:53: error: ‘int’ is not a class, struct, or union type
/usr/include/c++/4.6/bits/stl_iterator_base_types.h:170:53: error: ‘int’ is not a class, struct, or union type
उपयोग कर सकते हैं आप क्या करना चाहते हैं? –
मैं एक वेक्टर सरणी (गतिशील आकार के लिए) में डेटा स्टोर करना चाहता हूं, फिर डेटा बिंदुओं के बीच की दूरी की गणना करें। –