pointers

    3熱度

    3回答

    如果超出引用運算符(operator*),那麼成員選擇運算符(operator->)是否使用重載運算符,還是需要重載它?

    0熱度

    1回答

    希望任何人都可以幫助我。 我想弄清楚在一個方法的調用中傳遞一個對象的指針是什麼。 所以(在cocos2d的環境),這將是這樣的: - (void)loadCreature:(CCSprite*)creature { if (/*here I want to check if the pointer is 'blue'*/) NSLog(@"the creature is blue")

    4熱度

    4回答

    這是安全和正確的嗎?我的意思是刪除只關心它給出的地址,還是刪除原始指針變量很重要? myClass *p1 = new myClass(); myClass *p2 = p1; delete p2; p1 = NULL; p2 = NULL;

    1熱度

    3回答

    我有以下代碼: /* sample.c */ #include<stdio.h> #include<malloc.h> #include<stdlib.h> #include"hermes.h" #include<string.h> int main(){ struct hermes *h ; h = (stru

    11熱度

    7回答

    這是交易。我有一個大字符數組,並試圖操縱它。下面是一些代碼,我使用來測試這個想法: #include <stdio.h> char r[65536],*e=r; main() { e+=8; while(*e) { *e+=1; e+=5; *e-=1; e-=1; } *e+=1; prin

    1熱度

    4回答

    現在如何處理一個類的函數指針到另一個類的函數?這是我的問題 例子: class Apple { int(Apple::*pActionFunc)(void); }; class Tree { Apple* tempy; void Init(void); int I_Work(void); }; void Tree::Init(void)

    3熱度

    3回答

    我有以下主要功能,使用指針創建係數的乘積。這只是項目的一小部分,用於創建多項式: #include "header.h" int main() { TermProd x = TermProd(new Coeff(4), new Coeff(8)); x.print(); cout << endl; x = TermProd(new Coeff(8), new Co

    0熱度

    3回答

    我有一些我幾年前寫過的代碼。它一直在正常工作,但最近在其他地方重新編譯了一些新的,不相關的代碼後,它不再有效。這是代碼: //myobject.h ... inline CMapStringToOb* GetMap(void) {return (m_lpcMap);}; ... 以上是從主應用程序訪問像這樣: //otherclass.cpp ... CMapStringToOb*

    0熱度

    2回答

    我從文件存儲中讀取數據到列表中; 我要添加到列表的前面,我讀了。 插入似乎工作,但我的打印功能產生-1回報。 這是我的代碼: #include <stdio.h> #include <stdlib.h> 這是我的名單 typedef struct node{ int x,y,v; struct node* next; }node; 這是我的插入: node* insert(node

    0熱度

    3回答

    我似乎無法理解以下指針符號之間的區別,有人可以引導我嗎? typedef struct some_struct struct_name; struct_name this; char buf[50]; this = *((some_struct *)(buf)); 現在我想了一下週圍玩耍,做上述的事情,如: struct some_struct * this;