我对C++和Eclipse一般都很陌生,所以如果我遗漏了一些相当明显的东西,我会道歉.
我遇到的问题是我试图在我的一个源文件中包含一个头文件,但它们位于我的项目目录中的不同文件夹中.我不知道应该如何包括它们.我上传了一张图片,显示我想要包含突出显示的头文件的问题.

如果有人能告诉我'#include'声明我应该使用它们那将是非常棒的.
谢谢!
只是一个简单的问题:
如果我没有实际为其分配新值,是否需要删除指针?
如果我创建了一个指针然后将其引用给了类似的东西,我做了什么:
Planet *planetPointer;
planetPointer = &earth;
Run Code Online (Sandbox Code Playgroud)
我是否需要删除此指针或者我可以将其设置为null?
我以前遇到过这个问题,但找到了解决办法,只是这次解决办法不是一种选择.
我正在尝试使用'stof'函数,但我收到的错误是:'stof'不是'std'的成员'函数'stof'无法解析
如果在此页面上显示,我正在使用它:http://www.cplusplus.com/reference/string/stof/
这是我的包括:
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
Run Code Online (Sandbox Code Playgroud)
那么,我做错了什么?如果一个解决方案不能被发现可能有人点我的另一种方式将字符串转换为浮动,并把它抛出一个异常,如果字符串是不兼容?
编辑:使用示例程序和错误进行更新.
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
string testString = "";
float testFloat = 0.0;
testFloat = std::stof(testString);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
说明资源路径位置类型'stof'不是'std'main.cpp/Assignment/src第33行的成员C/C++问题
说明资源路径位置类型函数'stof'无法解析main.cpp/Assignment/src第33行语义错误
我正在将一个应用程序从WinForms移植到WPF,我试图获取选择在文本框中的位置的行号和列号时遇到了麻烦.我能够在WinForms中完成它,但WPF有一种完全不同的方式来实现RichTextBox,所以我不知道如何去做.
这是我的WinForms解决方案
int line = richTextBox.GetLineFromCharIndex(TextBox.SelectionStart);
int column = richTextBox.SelectionStart - TextBox.GetFirstCharIndexFromLine(line);
LineColumnLabel.Text = "Line " + (line + 1) + ", Column " + (column + 1);
Run Code Online (Sandbox Code Playgroud)
这不适用于WPF,因为您无法获取当前选择的索引.
这是工作解决方案:
int lineNumber;
textBox.CaretPosition.GetLineStartPosition(-int.MaxValue, out lineNumber);
int columnNumber = richTextBox.CaretPosition.GetLineStartposition(0).GetOffsetToPosition(richTextBox.CaretPosition);
if (lineNumber == 0)
columnNumber--;
statusBarLineColumn.Content = string.Format("Line {0}, Column {1}", -lineNumber + 1, columnNumber + 1);
Run Code Online (Sandbox Code Playgroud) 在我开始之前,我想解释一下,我是一个新手,很有可能我错过了一些简单的东西,或者有一些我不知道的简单的东西.
使用visual studio我想获得一些线程练习,但我无法将其包含在我的代码顶部.我知道这对C++ 11来说是新手,但是我不确定是否为Visual Studio 2010启用了它,或者不是我不确定我会怎么做.
这是我的代码的屏幕截图:
c++ ×4
c++11 ×2
.net ×1
c# ×1
eclipse ×1
header ×1
include ×1
include-path ×1
mingw ×1
pointers ×1
richtextbox ×1
visual-c++ ×1
wpf ×1
wpf-controls ×1