我一直在Windows XP上使用Code :: Blocks学习C++和Allegro,最近感觉就像学习Vim一样.但是,我不知道如何"手动"编译程序(即,不使用IDE).
为了从Vim中编译,我已经将makeprg设置为gcc,但我知道我还需要一个makefile.那是什么,我该怎么写?是否可以使用make文件,例如Allegro?
另外,我非常喜欢CB调试器(我正在使用gdb).是否有可能与Vim做类似的事情?
谢谢.
请忍受我,我只是在学习C++.
我正在尝试编写我的头文件(对于类),我遇到了一个奇怪的错误.
cards.h:21: error: expected unqualified-id before ')' token
cards.h:22: error: expected `)' before "str"
cards.h:23: error: expected `)' before "r"
Run Code Online (Sandbox Code Playgroud)
"期望不合格的身份"之前的'令牌'是什么意思?我做错了什么?
编辑:对不起,我没有发布整个代码.
/*
Card header file
[Author]
*/
// NOTE: Lanugage Docs here http://www.cplusplus.com/doc/tutorial/
#define Card
#define Hand
#define AppError
#include <string>
using namespace std;
// TODO: Docs here
class Card { // line 17
public:
enum Suit {Club, Diamond, Spade, Heart};
enum Rank {Two, Three, Four, Five, Six, Seven, Eight, Nine,
Ten, Jack, Queen, King, Ace};
Card(); // …Run Code Online (Sandbox Code Playgroud) 什么 - "了解一种语言"真的意味着什么?
我敢肯定,这不仅仅是了解语法.
是吗
你是如何学习你精通的语言的?
当使用Python 2.5.1运行时,此代码生成"AttributeError:'Popen'对象没有属性'fileno'"
码:
def get_blame(filename):
proc = []
proc.append(Popen(['svn', 'blame', shellquote(filename)], stdout=PIPE))
proc.append(Popen(['tr', '-s', r"'\040'"], stdin=proc[-1]), stdout=PIPE)
proc.append(Popen(['tr', r"'\040'", r"';'"], stdin=proc[-1]), stdout=PIPE)
proc.append(Popen(['cut', r"-d", r"\;", '-f', '3'], stdin=proc[-1]), stdout=PIPE)
return proc[-1].stdout.read()
Run Code Online (Sandbox Code Playgroud)
堆:
function walk_folder in blame.py at line 55
print_file(os.path.join(os.getcwd(), filename), path)
function print_file in blame.py at line 34
users = get_blame(filename)
function get_blame in blame.py at line 20
proc.append(Popen(['tr', '-s', r"'\040'"], stdin=proc[-1]), stdout=PIPE)
function __init__ in subprocess.py at line 533
(p2cread, p2cwrite,
function _get_handles in subprocess.py at line 830 …Run Code Online (Sandbox Code Playgroud) 如何使用ODBC连接从数据库中获取最后一个插入ID?
我正在寻找类似于mysql_insert_id()函数的解决方案.
这是一个数据库问题.我已经安装并运行了一个openid库.
我想在我正在使用的网站上使用OpenID.有三种类型的用户.
所有这些用户都存储在同一个表中,只是注释表.已命名的帐户会链接到该帐户可以管理的博客.匿名用户可以对博客上的文章发表评论,但他们无法做任何其他事情.如果匿名用户注册了某个帐户,我想自动将该用户的旧评论转移到指定帐户.我目前通过让用户填写具有唯一名称和有效电子邮件的表单来实现此目的.
目前,使用以下架构将两组帐户存储在同一个表中.(是的,它是铁路迁移)
create_table :users do |t|
t.string :name #unique because it maps to a subdomain
t.string :openid_url #unique
t.string :email #unique
t.string :password_hash
t.string :password_salt
t.boolean :guest #Anonymous user flag
t.timestamps
end
Run Code Online (Sandbox Code Playgroud)
(openid_url唯一的做法是防止多个帐户被连接到同一个openid.这email是唯一的,因为用户使用电子邮件/密码登录)
我正在使用此设置我遇到了Google的OpenID实施问题.使用Google for OpenID的每个用户都具有相同的网址:https://www.google.com/accounts/o8/ud.
我如何支持使用谷歌作为openid提供商,因为它的网址并不是每个用户都是唯一的?(请记住存在的约束)
注意:Google帐户可以使用互联网上的任何有效电子邮件地址,因此我不能将person@google.com存储在openid_url字段中,因为该电子邮件可能是person@example.com或更糟的是person@yahoo.com!雅虎也使用这种单一的网址方法,所以我也必须支持它们.
我正在从我写的一个类中得到一些非常奇怪的链接错误.我完全无法找到任何可以描述正在发生的事情的东西.
Visual Studio(Windows XP)
players.obj:错误LNK2019:未解析的外部符号"public:__thiscall TreeNode :: TreeNode(void)"(?? 0?$ TreeNode @ VPlayer @@@@ QAE @ XZ)在函数"public:__thiscall PlayerList :: PlayerList"中引用(void)"(?? 0PlayerList @@ QAE @ XZ)
Xcode(OSX 10.5)
未定义的符号:"TreeNode ::〜TreeNode()",引用于:player.o中的PlayerList :: ~PlayerList()
头文件:generics.h
class TreeNode : public BaseNode{
public:
const static int MAX_SIZE = -1; //-1 means any size allowed.
const static int MIN_SIZE = 0;
//getters
int size() const;
vector<C*> getChildren() const;
//setters
void setChildren(vector<C*> &list);
//Serialization
virtual void display(ostream &out) const;
virtual void read(istream &in);
virtual void write(ostream &out) const; …Run Code Online (Sandbox Code Playgroud) 我有一个项目(我正在学校),我正在挖掘Boost库中的解决方案.我需要一些方法来为我的应用程序分发所需的Boost源代码,以便可以编译它而不需要在进行编译的系统上安装库.(学校的电脑几乎没有你能提到的任何东西.学校去年安装了CVS.但他们确实有VS2005)
注意:我在Vista上使用Visual Studio 2005.我在我的系统上使用Boost 1.34.1我使用了自动安装程序.我遇到的文档说明了使用BCP命令,但该命令似乎没有复制任何东西.(我使用绝对路径来调用BCP,所以我最终不会调用错误的命令.)
编辑:我正在尝试使用RegEx库.
编辑:我用于BCP的命令是: "c:\Program Files\boost\boost_1_34_1\bin\bcp.exe" boost/regex.hpp regex\
它返回: no errors detected
我有一个看起来像这样的ruby哈希
{ "stuff_attributes" => {
"1" => {"foo" => "bar", "baz" => "quux"},
"2" => {"foo" => "bar", "baz" => "quux"}
}
}
Run Code Online (Sandbox Code Playgroud)
我想把它变成一个看起来像这样的哈希
{ "stuff_attributes" => [
{ "foo" => "bar", "baz" => "quux"},
{ "foo" => "bar", "baz" => "quux"}
]
}
Run Code Online (Sandbox Code Playgroud)
我还需要保留键的数字顺序,并且键的数量可变.以上是超简化的,但我在底部包含了一个真实的例子.最好的方法是什么?
PS
它还需要递归
就递归而言,这是我们可以假设的:
1)需要操作的键将匹配/ _attributes $/2)哈希将有许多其他键不匹配/ _attributes $/3)哈希中的键将始终是数字4)_attributes哈希可以在任何其他键下的任何哈希级别
这个哈希实际上是来自控制器中的创建动作的params哈希.这是使用此例程需要解析的内容的真实示例.
{
"commit"=>"Save",
"tdsheet"=>{
"team_id"=>"43",
"title"=>"",
"performing_org_id"=>"10",
"tdsinitneed_attributes"=>{
"0"=>{
"title"=>"",
"need_date"=>"",
"description"=>"",
"expected_providing_organization_id"=>"41"
},
"1"=>{
"title"=>"",
"need_date"=>"",
"description"=>"",
"expected_providing_organization_id"=>"41"
}
},
"level_two_studycollection_id"=>"27",
"plan_attributes"=>{
"0"=>{
"start_date"=>"", "end_date"=>""
} …Run Code Online (Sandbox Code Playgroud)