首页 | 本学科首页   官方微博 | 高级检索  
相似文献
 共查询到20条相似文献,搜索用时 156 毫秒
1.
C++动态数组的实现与重用   总被引:2,自引:0,他引:2  
数组是应用程序中经常要用到的一种数据结构。为解决C++定义后的数组不能改变其大小的情况,根据软件重用的思想,给出了用函数模板、动态数组类和数组类模板生成C++动态数组的方法,并对这些方法在代码重用方面进行了比较。文中主要给出了动态生成二维数组的函数模板、动态数组类和数组类模板的定义,以及部分成员函数和运算符重载函数的实现代码或算法。以动态生成二维整型数组,进行矩阵的加法运算为例,给出了使用方法。应用文中所给的方法,能满足应用程序中动态定义一维和二维数组的需要。  相似文献   

2.
作为一款优秀的快速应用程序开发工具(RAD),C++Builder为用户快速开发应用程序带来了很大的方便。由于C++Builder没有提供控件数组功能,这给应用程序开发者带来了一些不便。鉴于此,给出了动态生成控件的原理、动态生成控件的使用方法以及学习过程中的一点技巧。  相似文献   

3.
陈勇  常明 《计算机应用》1996,16(2):51-53
本文介绍了用C++语言和面向对象的思想分别在DOS系统和Windows系统中使用扩展内存开发大型二维数组类模板的构造方法及实现,并用Tif文件处理和汉字库装入等实例演示了它的使用方法。  相似文献   

4.
一个读取位图阵列的通用成员函数   总被引:1,自引:0,他引:1  
用VisualC 5.0为应用程序的文档类设计了一个读取BMP位图阵列到数组的通用成员函数.应用程序的视图类通过指向文档的指针可存取数组中的值,从而方便地完成对各象素点的操作.文中还给出了将存储在数组中的值写回到位图阵列的派代码。  相似文献   

5.
为C++语言开发长度可变的数组类模板   总被引:2,自引:0,他引:2  
本文详细讨论了可以代替C 数组的C 数组类模板的设计及实现过程,并举例说明了数组类模板的使用。  相似文献   

6.
模板是C^++中功能最强的特性之一,它允许编程人员只定义一个函数或类的“形状”。本文通过例子介绍了模板的使用,并给出了函数模板,类模板。  相似文献   

7.
C++教学中数组指针概念辨析   总被引:1,自引:0,他引:1  
贾震斌  陈珂 《福建电脑》2008,24(4):213-214
本文针对C++、C语言程序设计课程中二维及多维数组有关指针概念辨析的疑难点,通过引入指针基类型的概念解析一维、二维及多维数组指针的本质共性,提出了理解多维数组指针的一种比较有效的思路,试图解决多维数组教学中普遍存在的困惑。  相似文献   

8.
模板被誉为C++最强有力的机制之一,它在软件源代码重用方面起着很大作用,本文详尽探讨了模板的定义和实现及其对软件重用的支持,并阐述了笔者对BORLANDC++中由模板生成的基本类库的一些认识。  相似文献   

9.
C++编程实现可动态创建的无限维数组   总被引:1,自引:0,他引:1  
经常用到数组变量的C++程序编写人员肯定会碰到这样的问题:当数组的维数和大小只有在程序运行后才能知道时,如何声明该数组变量呢?由于数组变量声明时必须通过显式指定其大小(如:int A[2,3])或通过初始化(如:int A[]={{0,0},{0,0},{0,0}})隐式指定其大小,才能使编译器知道如何为该数组分配内存,所以使用普通的数组声明无法在程序运行过程中动态创建某一事先不知道大小的数组。当然,也可以有些变通的方法,如先创建一个足够大的数组等等,但这些无疑会浪费系统资源,降低程序效率。为此,笔者利用C++构造了一个可动态创建的、维数不限的数组模板类,以解决这个问题。  相似文献   

10.
徐迎晓 《电脑》1995,(4):59-59
结构化程序设计要求程序中的函数具有高度的独立性,即函数应尽可能地不依赖于全局变量.但在C语言中使用二维数组的场合,函数的独立性大受影响,它表现在两个方面:1、当数组名作为函数的参数进行传递时,若是传递一维数组,则可以动态地说明数组的长度,如:int sub(intlist[],int n).但若是传递二维数组,则在函数的参数表中必须说明数组的第二维最大长度,否则编译时将显示出错.通常的做法是利用宏定义预先定义数组的第二维最大长度,如:  相似文献   

11.
Dale Parson  Zhenyu Zhu 《Software》2000,30(15):1641-1660
The JavaTM Native Interface (JNI) provides a set of mechanisms for implementing Java methods in C or C++. JNI is useful for reusing C and C++ code repositories within Java frameworks. JNI is also useful for real‐time systems, where compiled C/C++ code executes performance‐critical tasks, while Java code executes system control and feature tasks. Available JNI literature concentrates on creating Java proxy classes that allow Java clients to interact with C++ classes. Current JNI literature does not discuss Java proxies for entire C++ inheritance hierarchies; that is the topic of this paper. Our experience in reusing C++ class hierarchies within a Java framework has uncovered a set of useful techniques for constructing Java proxy class hierarchies that mirror their C++ counterparts. This report gives both high level design guidelines and specific programming idioms for constructing Java class hierarchies that serve as proxies for C++ counterparts. We begin by discussing opportunities for reuse within a proxy class hierarchy, as well as problems caused by differences between the Java and C++ approaches to inheritance. The two most significant differences are due to C++ support for invocation of a member function based on the static type of its class, and C++ support for multiple implementation inheritance. Two example C++ class hierarchies provide the basis for a set of sections that present the design guidelines and that codify the programming idioms. This work could serve as the basis for an automatic generator of Java proxy class hierarchies. Copyright © 2000 John Wiley & Sons, Ltd.  相似文献   

12.
This article discusses an efficient implementation of tensors of arbitrary rank by using some of the idioms introduced by the recently published C++ ISO Standard (C++11). With the aims at providing a basic building block for high-performance computing, a single Array class template is carefully crafted, from which vectors, matrices, and even higher-order tensors can be created. An expression template facility is also built around the array class template to provide convenient mathematical syntax. As a result, by using templates, an extra high-level layer is added to the C++ language when dealing with algebraic objects and their operations, without compromising performance. The implementation is tested running on both CPU and GPU.  相似文献   

13.
最优化设计的程序实现方法决定了优化算法的执行效率及代码可读性,进而影响到优化设计在工程中的应用前景.最优化设计算法中常涉及到复杂的矩阵运算.通过分析比较几类实现矩阵运算的常用方法的优缺点,提出了基于C 表达式模板的最优化设计程序实现方法.最后,以DFP变尺度优化程序为实例,从程序可读性及执行效率上将几类方法进行了对比.结果表明,基于C 表达式模板实现的最优化设计程序在保证程序执行效率的基础上,能够提高程序的可重用性及可读性.  相似文献   

14.
针对卷积神经网络加速器中有关于脉动阵列模块的验证,提出并实现了一种基于直接编程接口C(DPI-C,Direct Programming Interface C)程序的验证平台,采用内嵌DPI-C程序并利用通用验证方法学(UVM,Universal Verification Methodology)满足脉动阵列模块中的浮点数乘加运算的验证需求。实验利用了SystemVerilog中的DPI接口技术,在验证平台中实现对C或C++代码的调用,通过编写C函数来实现复杂的参考模型,浮点数乘加运算便是利用C代码编写的。验证平台的整体结构是根据UVM来设计的,其中包括激励的设计、参考模型的编写、数据校对等组件,整个验证平台高效、简洁。此平台已经应用于人工智能芯片的验证工作中,编写的测试用例可以对脉动阵列进行充分验证,覆盖率达到了100%。验证平台可以保证脉动阵列验证的全面性、高效性并且调试纠错简单方便,同时还实现了UVM环境和测试用例的重用。  相似文献   

15.
Bruno Bachelet  Loïc Yon 《Software》2017,47(11):1521-1537
Concepts are likely to be introduced in a future C++ standard. They can be used for constraining template parameters, which enables checking requirements on template parameters sooner in the compilation process, and thus providing more intelligible error messages to the user. They can also be used in the specialization of templates, thus leading to a better control over the selection of the most appropriate version of a template for a given instantiation. This latter aspect offers new possibilities in the design of template libraries, as it enhances the specialization mechanism of templates, and set it up as a solid alternative to inheritance when static binding can replace dynamic binding. This article addresses the design of expression templates (i.e., templates that represent expressions and are usually built through operator overloading) that are useful to develop an embedded domain specific language (EDSL), and can speed up the evaluation of an expression by delaying the evaluation of intermediate operations to avoid unnecessary temporary objects. We propose to use concept‐based template specialization to parse expression templates in order to ease the design of an EDSL. This approach is a static variant of the well‐known visitor design pattern that replaces the overridden methods in the double dispatch of the original design pattern by template specializations based on concepts. An example of EDSL for linear programming developed with our solution demonstrates that a concept‐based design helps producing concise and reliable code. Copyright © 2017 John Wiley & Sons, Ltd.  相似文献   

16.
A program that accesses an out-of-bound array element can cause unexpected behaviour that is unacceptable to safety-critical or security-critical systems. Two traditional compile-time approaches to array bound checking are flow analysis and program verification. This paper presents a new approach, IFV, that integrates flow analysis and program verification techniques. IFV is generally about as effective as program verification yet runs in about the same time as flow analysis. Its typical runtime is proportional to the product of the program size and the number of declared variables. IFV matches loops to templates, which represent commonly occurring loop patterns, to discover loop invariants automatically, which it then uses to strengthen flow analysis. With only seven templates, it handles many common array-access patterns. Patterns not verified by flow analysis are processed with verification techniques entirely automatically. This paper also describes a prototype IFV system that performs compile-time array bound checking for programs in a subset of C. © 1997 John Wiley & Sons, Ltd.  相似文献   

17.
高晓雷  缪淮扣  李勇 《计算机工程》2006,32(11):50-57,5
主要介绍了用C++类模板实现Z规格说明语言中的类型,包括数据结构的设计、成员函数的设计。该模板的实现便于代码的重用和简化求精,从而提高软件开发的效率。  相似文献   

18.
国产异构众核处理器是我国打破国际技术壁垒,在高性能计算领域取得突破的关键环节.围绕国产超算的软件生态环境建设,采用智能源码转换的方法盘活海量多核架构的遗产代码是加速软件研发效率,推动领域发展的重要途径.针对国产运算核心不支持C++编译的现状,基于开源的ANTLR语言翻译工具,提出了一种面向异构众核处理器的智能化C++语...  相似文献   

19.
Class templates represent a difficulty for C++ garbage collectors since relevant information is available only very late, at instantiation time. Current collectors therefore either fail to work with class templates or have to run in a non‐optimized mode. This paper introduces the template garbage collector (TGC), the first mostly‐copying collector that can handle class templates. It discusses the design decisions that are suggested by the specifics of generic template programming and presents performance results and memory measurements of tests with MTL and GTL, two generic C++ libraries based on the Standard Template Library. The tests show that TGC substantially improves the run times of programs with many small objects with short lifetimes or large objects with long lifetimes. The memory usage at the same time is reasonable. Since TGC modifies the mostly‐copying technique, the heap sizes are in many cases considerably smaller than they are for traditional mostly‐copying collectors. The tests also show that TGC is competitive with the Boehm–Demers–Weiser collector, the most widely used collector for C++. Copyright © 2001 John Wiley & Sons, Ltd.  相似文献   

20.
Java code is organised around objects and classes rather than just functions, which enables the reuse of code in a very structured manner. Although Java syntax is similar to C++, it has not suffered from feature overload and is much less complex. In addition, some Java features, like garbage collection, are not entirely new but were pioneered by languages such as Lisp and Smalltalk. The paper discusses Java language features such as: inheritance, robustness, type safety, access modifiers, null pointer checking, array bounds checking, memory management, multithreading, garbage collection and security  相似文献   

设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号