设计电子表格 [英] Designing a spreadsheet
问题描述
嗨伙计们,
我正在尝试编写一个简单的(基于控制台/文本的)电子表格程序。我是一个相对的新手。
我之前编写的程序只是2D'box'只有一种数据类型(int ,浮动,char等)。现在我需要电子表格才能在单元格中存储不同的数据类型。
我对模板有一点了解,但我无法弄清楚如何链接我的2D矢量到单元格的输入值(如果有意义的话)。
我会感激任何帮助。
我尝试了什么:
我尝试过使用智能指针,但我对它们并不是很了解失败了。
Hi folks,
I'm trying to write a simple (console/text based) spreadsheet program. I'm a relative novice.
I have written programs before where the 2D 'box' was of one data type only (int, float, char etc). Now I need the spreadsheet to be able to store different data types in the cells.
I have a little knowledge of templates but I cannot figure out how to link my 2D vector to said input values of the cells (if that makes any sense).
I'd appreciate any help.
What I have tried:
I have tried using smart pointers but I don't really know much about them and failed miserably.
推荐答案
你的数组应该是一个指针数组。然后,每个指针都需要指向实现单元格引用的对象的类对象或结构。然后,每个对象都可以实现存储,操作和显示其内容所需的方法。
Your array should probaly be an array of pointers. Each pointer will then need to point to a class object or structure that implements the object referred to by the cell. Each object can then implement the methods necessary to store, manipulate and display its contents.
这篇关于设计电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!