अगर मैं अपने स्त्रोत फाइल में #include <vector.h>
डाल का कारण बनता है, मैं इस चेतावनी मिलती है:"vector.h" या "वेक्टर" भी शामिल है चेतावनियां या त्रुटियां
make -f Makefile CFG=Debug
g++ -c -g -o "Debug/mynn.o" "mynn.cpp"
In file included from C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/backward/vector.h:59,
from mynn.h:7,
from mynn.cpp:1:
**C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.**
g++ -g -o "Debug/mynn.exe" Debug/mynn.o
और अगर मैं सिर्फ #include <vector>
(ज बिना नियमित जोड़ने के लिए, चेतावनी की तरह चलता है), मैं निम्नलिखित त्रुटियाँ मिलती है:
make -f Makefile CFG=Debug
g++ -c -g -o "Debug/mynn.o" "mynn.cpp"
In file included from mynn.cpp:1:
**mynn.h:12: error: ISO C++ forbids declaration of `vector' with no type
mynn.h:12: error: expected `;' before '<' token
mynn.h:13: error: `vector' has not been declared
mynn.h:13: error: expected `,' or `...' before '<' token
mynn.h:13: error: ISO C++ forbids declaration of `parameter' with no type
mynn.h:20: error: ISO C++ forbids declaration of `vector' with no type
mynn.h:20: error: expected `;' before '<' token
mynn.h:21: error: ISO C++ forbids declaration of `vector' with no type
mynn.h:21: error: expected `;' before '<' token**
वहाँ एक बेहतर तरीका है इस सदिश हेडर को शामिल करने के लिए इतना है कि यह शिकायत नहीं करता है? यहाँ स्रोत फ़ाइल है कि चेतावनी/त्रुटियाँ पैदा करता है:
// mynn.h
#ifndef _MYNN_H_
#define _MYNN_H_
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <vector>
class neuron {
public:
neuron();
vector<int> weights;
int compute_sum (vector <int> &input);
};
class layer
{
public:
layer();
vector <neuron> nrns;
vector<int> compute_layer (vector <int> &input);
};
#endif /*_MYNN_H_*/
यदि आप सी ++ कोड लिख रहे हैं, तो सी स्टाइल हेडर के साथ गड़बड़ न करें। और का उपयोग करें। सी स्टाइल हेडर सी ++ स्टाइल हेडर के रूप में उपयोग किया जा सकता है: । –
Donotalo
'_MYNN_H_' एक आरक्षित पहचानकर्ता है, [इसका उपयोग न करें] (http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-ac-identifier)। – GManNickG