Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am using gcc under OS X and I get an error
fatal error: 'vector' file not found
when trying to include the vector implementation. Other includes like
#include <stdio.h>
#include <stdlib.h>
are working. Where is the vector file located?
vector is not part of C. You must use C++.
Try compiling with g++ rather than gcc
The vector C++ header enables the use of vector template class.
Include :
#include<vector>
and compile the program using g++.
Vector file you can add in c++ only, C doesn't support the vector property.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I'm currently reading a c++ book and one of the function is
void fp(char v[]){
for(char* p = v; *p!=0;p++) use(*p);
}
I wrote this into my editor and compiled it. I also included the headers
#include <iostream>
#include <string.h>
But my terminal returns the following message:
use of undeclared identifier 'use'
I also google it and its nowhere to be found online, the function doesn't exist.
That's because there is no such standard library function.
The author is either using pseudo-code here, or has defined this function somewhere else in the book.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I keep getting the error "vector does not name type" from one of my classes each time I try to compile my code.
#ifndef DISK
#define DISK
#include "PageTableEntry.h"
#include <vector>
class disk{
private:
Vector <PageTableEntry*> frames;
public:
void addFrame(int Location, PageTableEntry* pte);
void removeFrame(int pteLocation);
Disk();
};
#endif
You should quote errors verbatim. I assume the error is actually more along the lines of Vector does not name type.
You have either not included the declaration for Vector in your code, doing so would provide the compiler with a type, or you have (more likely) mistakenly written Vector when it should be std::vector. Letter case and namespaces matter in C++.
Try:
std::vector<PageTableEntry*> frames;
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
Hi guys I am just starting to use C++ and I have a problem when I run this short code
#include <cmath>
#include <iostream>
int main()
{
std::cout << std::legendre(3, 0.25);
}
I get that std does not contain legendre, but I am fairly sure it is in cmath. Can someone give advice?
std::legendre was introduced in C++ since C++17. gcc compiles your code with no problem since version 7, clang since version 5 and MSVC since preview 2018 https://godbolt.org/z/reoiaD
You need to enable C++17 with -std=c++17 and possibly update your compiler.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
Writing a recent Windows Store app, I was surprised that I could make use of the std::string type without having to include its header. More specifically, the following code compiles without any errors:
StringExample.h:
#pragma once
class StringExample
{
public:
std::string str;
};
StringExample.cpp:
#include "pch.h"
#include "StringExample.h"
#include <string>
Removing the string include from the .cpp file makes the compiler fail. Shouldn't the string header already be required in the header file?
My bad. I double-checked the order of the includes in an empty project, and the .cpp file indeed needs to look like this for this to occur:
#include "pch.h"
#include <string>
#include "StringExample.h"
Thus, including <string> allows StringExample.h to compile, whereas removing the include makes it fail.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I've seen a couple of programs that have a blank #include at the beginning. I would like to know what's the purpose behind this?
Like this:
#include
#include <iostream>
// include more stuff
Example Link: http://mkaczanowski.com/beaglebone-black-cpp-gpio-library-for-beginners/#important_methods
The preprocessor that spits out the formatted HTML code for the link you posted is buggy. Look at the source code on GitHub and you'll see, it should look like this:
#include <iostream>
#include "GPIO/GPIOManager.h"
#include "GPIO/GPIOConst.h"
...
As an FYI, the code you submitted can't compile. It is illegal in C++ to simply have a line that says #include. The compiler will expect a file to follow so it knows what to include.