关于指针 [英] About pointer

查看:71
本文介绍了关于指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我是Sandeep Patil。我在c和c ++中有一个关于指针的问题。

什么是指针函数?它是地址运算符。我们使用指针来存储变量的地址来引用该变量。那么为什么我们使用char指针,int指针作为不同的指针。为什么我们不应该使用一种类型的指针来引用所有类型的变量?

Hello,
I am Sandeep Patil. I have one question about pointer in c and also c++.
What is function of pointer? it is address operator. We use pointer to store address of variable to refer that variable. Then why we use char pointer, int pointer as a different pointers. Why should we not use one type of pointer to refer all types of variable?

推荐答案


你好,

我是Sandeep Patil。我在c和c ++中有一个关于指针的问题。

什么是指针函数?它是地址运算符。我们使用指针来存储变量的地址来引用该变量。那么为什么我们使用char指针,int指针作为不同的指针。为什么我们不应该使用一种类型的指针来引用所有类型的变量?
Hello,
I am Sandeep Patil. I have one question about pointer in c and also c++.
What is function of pointer? it is address operator. We use pointer to store address of variable to refer that variable. Then why we use char pointer, int pointer as a different pointers. Why should we not use one type of pointer to refer all types of variable?



指针类型即字符或整数用于表示它们指向的内容。

例如你可以在分配给的空间中存储一个字符整数


int * p = new int;

* p =(int)''c'';


但是根据编译器仍然* p包含int而不是字符。

我认为这回答了你的问题

Pointer types ie character or integer is to indicate what they are pointing to.
for example u can store a character in space allocated to integer

int * p = new int;
*p = (int)''c'';

But according to compiler still *p contains int and not character.
I think this answered your question


指针仍然是相同的无关。 />
字符指针和整数指针之间的区别在于字符指针将VALUE视为字符,而整数指针将VALUE视为整数....... br />

The pointer is still the same irrespective.
The difference between a character pointer and an integer pointer, is that a character pointer treats the VALUE where it is pointing as a character, while an integer pointer treats the VALUE as an integer.....
:
展开 | 选择 | Wrap | 行号



你好,

我我是Sandeep Patil。我在c和c ++中有一个关于指针的问题。

什么是指针函数?它是地址运算符。我们使用指针来存储变量的地址来引用该变量。那么为什么我们使用char指针,int指针作为不同的指针。为什么我们不应该使用一种类型的指针来引用所有类型的变量?
Hello,
I am Sandeep Patil. I have one question about pointer in c and also c++.
What is function of pointer? it is address operator. We use pointer to store address of variable to refer that variable. Then why we use char pointer, int pointer as a different pointers. Why should we not use one type of pointer to refer all types of variable?



我想谈谈为什么你不能为所有变量都有一种指针。答案与地址计算有关。如果你有指针,ptr:

I would like to talk about why you can''t have one kind of pointer for all variables. The answer has to do with address calculations. If you have pointer, ptr:

展开 | 选择 | Wrap | 行号


这篇关于关于指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆