- 浏览: 399998 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (309)
- xaml C# wpf (0)
- scala java inner clas (1)
- Tools UML Eclipse UML2 (1)
- Timer .NET Framework (1)
- perl (6)
- python function paramter (1)
- Python Docstring (1)
- Python how to compare types (1)
- Python (8)
- java (5)
- C# (76)
- C# WPF (0)
- p4 (0)
- WPF (46)
- .net (6)
- xaml (1)
- javascript (40)
- windows (10)
- scala (4)
- winform (1)
- c++ (48)
- tools (12)
- cmd (1)
- os (0)
- CI (0)
- shell (0)
- C (2)
- haskell (49)
- functional (1)
- tool (1)
- gnu (1)
- linux (1)
- kaskell (0)
- svn (0)
- wcf (3)
- android (1)
最新评论
YOu can overload the -> or the * operator, which is callled the reference and dereference operator separtely...
You can overload the operator if you see necessary, here is soem cdoe shows how you can use it.
the header file
/** * file * Screen.h * * description: * this is the header file definition of the screen and the ScreenPtr */ class Screen { public: void move(int x, int y); private: protected: }; class ScreenPtr { public: ScreenPtr(Screen *ptr_) : ptr(ptr_) { } Screen& operator*() { return *ptr; } Screen* operator->() { return ptr; } ~ScreenPtr() { delete ptr; } // we shall we define the operator as well private: Screen *ptr; protected: };
the cpp implementation file.
/** * file * Screen.h * * description: * this is the header file definition of the screen and the ScreenPtr */ #include "stdafx.h" #include "Screen.h" #include <iostream> using std::cout; using std::endl; using std::cerr; void Screen::move(int x, int y) { cout << "Screen move -> x: " << x << " y: " << y << endl; } /** * point is examined to determine its type, if point is a pointer of some class type, the statement use the semantics of the built-in members * access operator new . if point is an object or a reference of some class type, the class is examined for an overloaded member access operator arrow. */ void test_use_of_ptr_overload() { Screen *screen = new Screen(); ScreenPtr ptr(screen); ptr->move(1, 2); }
one important thing about the semantic of the -> and * operator.
point is examined to determine its type, if point is a pointer of some class type, the statement use the semantics of the built-in members. access operator new . if point is an object or a reference of some class type, the class is examined for an overloaded member access operator arrow.
发表评论
-
不安装Visual Studio,只用Windows SDK搭建VC环境
2013-12-31 21:52 15342首先你需要下载的是 Microsoft Windows S ... -
rpath - runtime search path
2013-04-03 11:36 1013RPath is a very interesting to ... -
C++ - autogenerated copy constructor and assignment operator gotchas
2013-01-24 13:32 772It has been changed that the s ... -
c++ - rethrow a exception gotchas
2012-12-23 10:57 964As in my prevoius example in j ... -
c++ -typeid operator
2012-10-15 22:30 1060typeid is the one of the meager ... -
c++ - dynamic_cast revisit
2012-10-14 21:21 774There are several built-in type ... -
c++ - virtual inheritance example 1
2012-10-14 15:25 826we have discussed the virtual i ... -
c++ - virtual inheritance
2012-10-12 08:58 980As we have discussed in the pos ... -
c++ type of inheritance
2012-09-28 08:58 754There are 3 types of inheritanc ... -
c++ - vritually virtual new
2012-09-27 23:59 961Let's see what if we want to cl ... -
c++ - virtual destructor
2012-09-27 22:01 976As we all know that virtual des ... -
c++ - vritual function and default arguments
2012-09-27 08:56 995As we all know that we virtual ... -
c++ - template specialization and partial specialization
2012-09-26 22:38 1331in this post, we are going to e ... -
c++ - member template in class template
2012-09-26 08:19 940class member template can be us ... -
c++ template class and the pattern to use its friends
2012-09-25 23:47 987template class may defined thei ... -
c++ - Friend declaration in class Template
2012-09-25 08:47 1213There are three kinds of friend ... -
c++ - class template default parameters
2012-09-25 08:18 856the template has parameter, it ... -
c++ - operator new and delete and an example of linked list stores by new/delete
2012-09-24 07:53 589The operator new and delete ope ... -
c++ - delete(void *, size_t) or delete(void *)
2012-09-24 07:18 1172In my previous dicuss, we have ... -
c++ - placement operator new() and the operator delete()
2012-09-23 15:22 875A class member operator new() c ...
相关推荐
然而,当使用C++的`Json::Value`库(如JsonCpp)时,可能会遇到“Use of overloaded operator [] is ambiguous”这样的编译错误。这个错误通常发生在尝试使用0作为数组下标访问`Json::Value`对象时。 在C++中,`[]`...
The goal of this guide is to manage this complexity by describing in detail the dos and don'ts of writing C++ code. These rules exist to keep the code base manageable while still allowing coders to ...
WOLK是稳定的开发内核,其中包含许多项目中的许多有用补丁。 目标:稳定性,可伸缩性,性能,最重要的是:安全性。
RSP-20372 A generic "reference to function" will only match the first of several overloaded functions RSP-19714 Win32 compiler - Memory corruption with array helpers RSP-18241 *.c source files, added ...
The `std::string` class in the C++ Standard Library addresses these limitations by providing a true string type that supports common operations through both member functions and overloaded operators....
- FIX: In "Windows ClearType" font rendering mode (OS Windows mode) the "garbage" pixels can appear from the right and from the bottom sides of the painted rectangle of the TFlexText object....
Exploring C++ divides C++ up into bite-sized chunks that will help you learn the language one step at a time. Assuming no familiarity with C++, or any other C-based language, you’ll be taught ...
可重载声明(Overloadable declarations)、声明匹配(Declaration matching)、重载解析(Overload resolution)、重载函数的地址(Address of overloaded function)、重载运算符(Overloaded operators)、内建...
尝试捕获超载该软件包包含重载Try / Catch语句的功能。动机添加自定义错误需要手动检查哪种类型的错误我们收到的是catch块,因为JS没有catch过载。 例如class UserNotFoundError extends Error { // ......
鸣谢:CSDN上supermegaboy君的C/C++左值性精髓,读后略有所感,空闲时重构了下大学时的作业,着重区分了函数返回值的左右值 =================================================附录:接口函数======================...
此外,C++ Primer Plus第五版深入讲解了指针(pointer),这是C++中独特的特性,它允许我们直接操作内存地址。源码中包含了对指针的深入实践,如指针与数组的关系、指针与函数的关系,以及智能指针(smart pointers...
we do not guarantee C++Builder will install the packages at this time! - Added support for mtifoNullFirst in index definition, which indicates NULL values to be treated lower than any other value ...
- **重载函数(Overloaded Functions)**:C++允许函数名相同但参数列表不同的函数存在,这就是重载。通过这种方法,一个函数可以根据传入的不同参数类型执行不同的操作。 - **模板函数(Template Functions)**:...
we do not guarantee C++Builder will install the packages at this time! - Added support for mtifoNullFirst in index definition, which indicates NULL values to be treated lower than any other value ...
5. **重载函数(Overloaded Functions)**:C++允许在同一作用域内用相同的名字定义多个函数,只要它们的参数列表不同即可。这是实现方法多态性的一种方式。 6. **默认参数(Default Arguments)**:在定义函数时...
鸣谢:CSDN上supermegaboy君的C/C++左值性精髓,读后略有所感,空闲时重构了下大学时的作业,着重区分了函数返回值的左右值 =================================================附录:接口函数======================...
Please note that the “See Also” sections refer to Win32 API functions by prefacing them with the scope resolution operator (::), for example, ::EqualRect. More information on these functions can be ...
在Windows XP Service Pack 3(XP SP3)环境中,"Overloaded-kernel-for-XPSP3.rar" 提供了一个经过重载的内核,这表明它可能包含了对原始XP内核的修改或扩展,以实现特定的目标。这种内核通常由开发人员使用Windows...
- **#define定义预定义**:虽然不是Java中的概念,但这里指的可能是C/C++中的宏定义,用于定义常量或者函数等。 - **Abstract抽象的**:用于修饰类或者方法,表明它们不能被实例化,只能作为其他类的基类。 ##### -...