网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
08月27日漏签0天
c++吧 关注:630,503贴子:2,113,814
  • 看贴

  • 图片

  • 吧主推荐

  • 游戏

  • 6回复贴,共1页
<<返回c++吧
>0< 加载中...

c++指针问题

  • 只看楼主
  • 收藏

  • 回复
  • girlwraith
  • ,
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
string* s = new string("asdas");

cout << *s << endl;

这样不能通过编译(gcc)是为什么?


  • 128.227.248.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
error message, please


2025-08-27 00:02:41
广告
不感兴趣
开通SVIP免广告
  • girlwraith
  • ,
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
In file included from C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../includ
e/c++/3.4.2/backward/iostream.h:31,
 from ds.cpp:12:
C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/backward/b
ackward_warning.h:32:2: warning: #warning This file includes at least one deprec
ated or antiquated header. Please consider using one of the 32 headers found in
section 17.4.1.2 of the C++ standard. Examples include substituting the <X> head
er for the <X.h> header for C++ includes, or <iostream> instead of the deprecate
d header <iostream.h>. To disable this warning use -Wno-deprecated.
S:\TEMP/ccCObaaa.o(.text+0xd):ds.cpp: undefined reference to `std::string::size(
) const'
S:\TEMP/ccCObaaa.o(.text+0x60):ds.cpp: undefined reference to `std::string::oper
ator[](unsigned int) const'
S:\TEMP/ccCObaaa.o(.text+0x9f):ds.cpp: undefined reference to `std::string::oper
ator[](unsigned int) const'
S:\TEMP/ccCObaaa.o(.text+0xce):ds.cpp: undefined reference to `std::string::oper
ator[](unsigned int) const'
S:\TEMP/ccCObaaa.o(.text+0x134):ds.cpp: undefined reference to `__gxx_personalit
y_sj0'
S:\TEMP/ccCObaaa.o(.text+0x169):ds.cpp: undefined reference to `std::allocator<c
har>::allocator()'
S:\TEMP/ccCObaaa.o(.text+0x18a):ds.cpp: undefined reference to `std::basic_strin
g<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*
, std::allocator<char> const&)'
S:\TEMP/ccCObaaa.o(.text+0x19d):ds.cpp: undefined reference to `std::allocator<c
har>::~allocator()'
S:\TEMP/ccCObaaa.o(.text+0x1c0):ds.cpp: undefined reference to `std::allocator<c
har>::~allocator()'
S:\TEMP/ccCObaaa.o(.text+0x1ce):ds.cpp: undefined reference to `std::cout'
S:\TEMP/ccCObaaa.o(.text+0x1da):ds.cpp: undefined reference to `std::basic_ostre
am<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>
, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std
::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
S:\TEMP/ccCObaaa.o(.text+0x1e2):ds.cpp: undefined reference to `std::basic_ostre
am<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std:
:basic_ostream<char, std::char_traits<char> >&)'
S:\TEMP/ccCObaaa.o(.text+0x1ea):ds.cpp: undefined reference to `std::ostream::op
erator<<(std::ostream& (*)(std::ostream&))'
S:\TEMP/ccCObaaa.o(.text+0x1fc):ds.cpp: undefined reference to `std::basic_strin
g<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
S:\TEMP/ccCObaaa.o(.text+0x232):ds.cpp: undefined reference to `std::basic_strin
g<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
S:\TEMP/ccCObaaa.o(.text+0x281):ds.cpp: undefined reference to `std::ios_base::I
nit::Init()'
S:\TEMP/ccCObaaa.o(.text+0x29c):ds.cpp: undefined reference to `std::ios_base::I
nit::~Init()'
collect2: ld returned 1 exit status


  • girlwraith
  • ,
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
楼上这不是java啊.. 怎么可能转换string和string*呢..


  • girlwraith
  • ,
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include <iostream>
#include <string>

using namespace std;

int main()
{
 string* s = new string("adsasd");

 cout << *s << endl;
 return 0;

}

这样的code能在dev c通过, 能在VC9通过, 但用cmd的时候就有很多不知道是什么的err
就这样:
gcc a.cpp


  • girlwraith
  • ,
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
我错了.. 应该用g++ a.cpp这样编译


  • Leeroy
  • |
    7
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
……多好的结果


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 6回复贴,共1页
<<返回c++吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示