我有使用C#编程的经验,但是这个学期我正在学习C++课程,我正在编写我的第二个项目,但是当我尝试构建程序的调试配置时,我不断收到此错误.
我的构建日志如下,有关于发生了什么的任何想法?我不知所措.
感谢大家!
1>------ Rebuild All started: Project: Project_2, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'Project_2', configuration 'Debug|Win32'
1>Compiling...
1>main.cpp
1>Linking...
1>LINK : C:\Users\Alex\Documents\Visual Studio 2008\Projects\Project_2\Debug\Project_2.exe not found or not built by the last incremental link; performing full link
1>Embedding manifest...
1>Project : error PRJ0002 : Error result 31 returned from 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe'.
1>Build log was saved at "file://c:\Users\Alex\Documents\Visual Studio 2008\Projects\Project_2\Project_2\Debug\BuildLog.htm"
1>Project_2 - 1 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, …Run Code Online (Sandbox Code Playgroud) 我是第一个C++类的编程学生,最近我们被鼓励编写一个简单的递归函数来查找给定字符串中第一次出现的子字符串.如果找到,则返回索引.如果未找到子字符串,则该index_of()函数应返回-1.我们鼓励使用一个辅助函数,它将索引作为其参数之一,这就是我尝试过的.
例如:
int index_of("Mississippi", "sip"); // this would return a 6
Run Code Online (Sandbox Code Playgroud)
这应该是一个简单的练习,以帮助我们理解递归,并且不会被提交.我的教授说我们实际的递归赋值将更加复杂,这就是为什么我真的想要理解递归的简单用法.
我已经使用C风格的字符串和指针成功完成了这项工作,但没有使用C++ std :: string对象.我的节目中我做错了什么?我的教授表示我们应该能够在5分钟内轻松写出来,但我已经苦苦挣扎了两个小时.这是我到目前为止所做的:
int index_of(string s, string t)
{
int index = 0;
if (s[index] == NULL)
return -1;
else if (starts_with(s, t, ++index))
{
return index;
}
else
return index;
}
bool starts_with(string s, string t, int index)
{
if (t[index] == NULL)
return true;
if ( s[index] == NULL || t[0] != s[index])
return false;
return starts_with(s, t, ++index);
}
Run Code Online (Sandbox Code Playgroud)
如上所述,此函数始终返回index1.
我正在使用wxWidgets为我的C++编程类开发一个程序.我遇到了一个很大的问题,我的事件处理程序(我假设)没有被调用,因为当我点击按钮触发事件时,没有任何反应.我的问题是:你能帮助我找到问题并解释为什么他们不会被调用吗?
事件处理程序OnAbout和OnQuit正在运行,而不是OnCompute或OnClear.我真的很沮丧,因为我无法弄清楚这一点.提前谢谢!
#include "wx/wx.h"
#include "time.h"
#include <string>
using std::string;
// create object of Time class
Time first;
class App: public wxApp
{
virtual bool OnInit();
};
class MainPanel : public wxPanel
{
public:
// Constructor for panel class
// Constructs my panel class
// Params - wxWindow pointer
// no return type
// pre-conditions: none
// post-conditions: none
MainPanel(wxWindow* parent);
// OnCompute is the event handler for the Compute button
// params - none
// preconditions - none
// …Run Code Online (Sandbox Code Playgroud) 根据jQuery文档,我需要转义在我的选择器字符串中出现的元字符,当它们作为文字出现时.但是,我找不到很多关于何时何时不逃避选择器的具体例子.因此,当我不需要转义元字符时,当它们被解释为文字时,在:
属性选择器?即
$("[attr=value]")
Run Code Online (Sandbox Code Playgroud)
Id选择器?即
$("#id")
Run Code Online (Sandbox Code Playgroud)
班级选择器?即
$(".class");
Run Code Online (Sandbox Code Playgroud)
并且,有没有办法编写一个函数来替换选择器字符串中的metachars,同时仍然保留起始字符?即:
// replace all meta chars, preserving the id selection?
$("#id.rest$of*string")
// replace all meta chars, preserving the attribute selection?
// going back to my previous question, do I even need to escape the metachars in this situation?
$("[attr=blah.dee#foo*yay]")
Run Code Online (Sandbox Code Playgroud)
我问这个问题的原因是因为我正在使用一个恰好有一些非常讨厌的选择器的网站.而且我无法控制网站,因此我无法更改选择器以便更好地使用.
谢谢!!
我对存储库中的特定文件进行了一些更改,并提交了这些更改.全部在一次提交下.
在那次提交中,我还对其他几个文件进行了更改.如何取消对我对该特定文件所做的更改,而不是所有在提交中更改的文件?
我刚刚完成了我的第二个OOP课程,我的第一和第二课程都是用C#教授的,但对于我的其他编程课程,我们将使用C++.具体来说,我们将使用visual C++ compliler.问题是,我们需要自学C++的基础知识,而我们的教授没有过渡.所以,我想知道你是否有人知道我可以去学习C++的一些好资源,来自ac #background?
我问这个是因为我注意到C#和C++之间存在很多差异,例如声明你的main方法int,并返回0,并且你的main方法并不总是包含在类中.另外,我注意到你的所有类都必须在main方法之前编写,我听说这是因为VC++从上到下符合要求?
无论如何,你知道一些好的参考资料吗?
谢谢!(另外,在那里我可以比较一下我用C#编写的简单程序,看看它们在C++中的样子,比如我下面写的那个)?
using System;
using System.IO;
using System.Text; // for stringbuilder
class Driver
{
const int ARRAY_SIZE = 10;
static void Main()
{
PrintStudentHeader(); // displays my student information header
Console.WriteLine("FluffShuffle Electronics Payroll Calculator\n");
Console.WriteLine("Please enter the path to the file, either relative to your current location, or the whole file path\n");
int i = 0;
Console.Write("Please enter the path to the file: ");
string filePath = Console.ReadLine();
StreamReader employeeDataReader = new StreamReader(filePath); …Run Code Online (Sandbox Code Playgroud) 我是一名试图更好地理解指针的编程学生,我学到的一点是你可以设置指向NULL的指针.我的问题是,这两个陈述有什么区别?什么时候他们会返回真/假?
if (some_ptr == NULL)
if (*some_ptr == NULL)
Run Code Online (Sandbox Code Playgroud)
谢谢!
我在一个由4人组成的工程团队工作,主要是编写javascript,偶尔也会涉及ruby和python.因此,作为一个团队,我们一直在共享代码,而且正如大多数程序员所做的那样,团队中的每个成员都有他最喜欢的缩进级别和相关设置.我是团队的两名成员之一,他们使用并喜欢Vim作为我的主要代码编辑器.我喜欢我的团队,但我也喜欢我的缩进,这恰好使用了4个空格的制表符.有关更多上下文,这是我在.vimrc中使用的内容:
set ts = 4 sts = 4 sw = 4 expandtab " 4 space tabs
Run Code Online (Sandbox Code Playgroud)
随着团队中进行如此多的代码共享和协作编辑,主代码文件通常开始显示为大量混合选项卡和空间混乱,因此即使是经典的Vim技巧选择所有并按下=智能缩进也不会有很大的影响.
无论如何,我的问题是:在Vim(特别是MacVim)是否有更好的(更可靠的)方法将代码文件从凌乱的混合缩进转换为我喜欢的缩进?无论是.vimrc设置还是我在编辑文件时输入的命令,我都不在乎.
感谢您的任何建议!
我想使用指针来反转C++中的char数组.我想知道是否有什么我应该采取不同的做法?我这样做了吗?有没有更有效的方法来实现这一目标?
我的小程序:
int main ( )
{
char buffer[80];
PrintHeader();
cout << "\nString reversal program";
cout << "\nType in a short string of words.";
cout << "\nI will reverse them.";
cout << "\n:";
cin.getline(buffer, 79);
cout << "\nYou typed " << buffer;
reverse (buffer);
cout << "\nReversed: " << buffer;
cout << endl;
system("PAUSE");
return 0;
}
void reverse(char* string)
{
char* pStart, *pEnd;
int length;
char temp;
length = strlen(string);
pStart = string;
pEnd = &string[length - 1];
while(pStart …Run Code Online (Sandbox Code Playgroud) 我是第一个C++类的编程学生,最近我们获得了一个赋值来实现一个递归程序,该程序查找给定字符串中给定子字符串的第一次出现.
例如:
int StringIndex("Mississippi", "sip"); // this would return 6
Run Code Online (Sandbox Code Playgroud)
我们给出的提示是使用递归辅助函数,该函数将索引作为参数.
这是我到目前为止所做的:
int index_of(string s, string t)
{
int index = 0;
if (s[index] == NULL)
return -1;
else if (starts_with(s, t, ++index))
{
return index;
}
return index_of(s, t);
}
bool starts_with(string s, string t, int index)
{
if (t[index] != s[index] || s[index] == NULL)
return false;
return starts_with(s, t, ++index);
}
Run Code Online (Sandbox Code Playgroud)
我收到堆栈溢出错误,我不明白为什么.那么有人会介意帮助我理解为什么我会收到这个错误吗?并帮助我指出正确的方向,如何解决它?
c++ ×7
pointers ×2
recursion ×2
arrays ×1
build-error ×1
c# ×1
debugging ×1
dereference ×1
escaping ×1
git ×1
indentation ×1
javascript ×1
jquery ×1
macvim ×1
null ×1
oop ×1
string ×1
transition ×1
vim ×1
wxwidgets ×1