小编Fik*_*tik的帖子

`auto`的ref-和cv-stripping属性.

我了解到以这种方式使用auto声明变量

auto var = expr;
Run Code Online (Sandbox Code Playgroud)

基本上就是从它的类型expr和剥离&/ && - 引用和所有顶级constness和volatile.这是否意味着上述行完全等同于以下内容?

std::remove_cv<std::remove_ref<decltype(expr)>::type>::type var = expr;
Run Code Online (Sandbox Code Playgroud)

c++ decltype auto c++11

10
推荐指数
1
解决办法
241
查看次数

是否有可能将一个对象转发给一个没有在C++中定义额外变量或vtable的子类?

是否有可能将对象向下转换为子类并不定义任何额外的变量或虚方法?

如果我有这些课程,

class A { public: A (); };
class B : public A { public: void method1 () {} B (); };
Run Code Online (Sandbox Code Playgroud)

这是(1)可能和(2)标准安全吗?

A* a = new A ();
B* b = (B*)a;
b->method1();
Run Code Online (Sandbox Code Playgroud)

c++ downcast

9
推荐指数
2
解决办法
924
查看次数

Koenig的查找是否适用于此处?

以下代码段正确的C++代码是什么?

#include <sstream>
class Foo;
std::ostream& operator<<(std::ostream& str, Foo x);  // (A)

namespace test {
  class Message {
  public:
    std::ostringstream str;
  };

  template<typename T>
  Message& operator<<(Message& m, T& t)
  {
    using ::operator<<;
    m.str << t;
    return m;
  }
}

namespace detail {
  class Class {
  public:
    int i;
    Class() : i(5) {}
  };
}

std::ostream& operator<<(std::ostream& str, detail::Class& myClass) { // (B)
  return str << myClass.i;
}

int main() {
  test::Message m;
  detail::Class c;
  m << c;
}
Run Code Online (Sandbox Code Playgroud)

根据http://goo.gl/NkPNau,GCC …

c++

5
推荐指数
1
解决办法
176
查看次数

在Ubuntu 11.10上编译C++和OpenSSL

我在Ubuntu 11.10上编译我的C++和OpenSSL项目时遇到了严重的问题.编译命令是:

g++ -Wall -lssl -lm -lcrypto -I ./src ./src/server.cpp -o ./bin/server
Run Code Online (Sandbox Code Playgroud)

我收到这些错误:

server.cpp:(.text+0x8ff): undefined reference to `RSA_new'
server.cpp:(.text+0x92d): undefined reference to `PEM_read_RSAPrivateKey'
server.cpp:(.text+0xa85): undefined reference to `RSA_size'
server.cpp:(.text+0xaa1): undefined reference to `RSA_size'
server.cpp:(.text+0xae7): undefined reference to `RSA_private_decrypt'
server.cpp:(.text+0xd84): undefined reference to `BF_set_key'
server.cpp:(.text+0xf1d): undefined reference to `BF_ecb_encrypt'
server.cpp:(.text+0x13c6): undefined reference to `BF_ecb_encrypt'
collect2: ld returned 1 exit status
make: *** [server] Error 1
Run Code Online (Sandbox Code Playgroud)

我成功安装了openssllibssl-dev,但问题仍然存在.我尝试使用内核3.0在Linux Mint 12上编译项目,我遇到了同样的问题.在我使用内核2.6的旧Linux操作系统上,项目编译并运行良好(使用相同的Makefile和相同的源代码).请帮我!

c++ openssl g++

3
推荐指数
1
解决办法
4584
查看次数

标签 统计

c++ ×4

auto ×1

c++11 ×1

decltype ×1

downcast ×1

g++ ×1

openssl ×1