C ++最佳实践,OOD,链表 [英] C++ Best practices, OOD, Linked List

查看:95
本文介绍了C ++最佳实践,OOD,链表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




在C ++中,以下是否考虑过最佳实践?

- 将aguments传递给函数(即函数不带任何参数



- 使用return语句返回值


还有别的吗?


这个问题的原因是我有一个作业,其中我要求b $ b要求修改,以便主要调用主要的所有功能

本身也不通过除了第一个函数之外的任何参数。


另一个问题是LinkedList。我不应该通过Head

指针或添加一个全局变量。该类只有* m_pLink(

尾指针)。是否可以将头指针分配给m_pLink

(m_pLink确实获取当前指针值,因为它在

链上进行,但是分配了当前最高指针值)?我这样做了,

代码工作正常。


谢谢

解决方案



2005写道:





在C ++中,是以下是否考虑过最佳实践?

- 将遗产传递给函数(即函数不带任何参数




嗯?将参数传递给不带

参数的函数是一种好习惯吗?那是你在问什么?不它不是。它甚至不会编译b
。通常,当函数

需要输入或参数时,会将参数传递给函数。


- 使用return语句返回值



你还会怎样返回值?


>

还有别的吗?



你的帖子没有多大意义。也许你需要更清楚地想一想你要问的是什么。


>

原因这个问题是我有一个作业,其中我要求b $ b要求修改,以便main将调用main

本身的所有函数,并且也不传递任何参数除了第一个功能。



好​​的。


>

另一个问题是LinkedList。我不应该通过Head

指针或添加一个全局变量。该类只有* m_pLink(

尾指针)。是否可以将头指针分配给m_pLink

(m_pLink确实获取当前指针值,因为它在

链上进行,但是分配了当前最高指针值)?我这样做了

代码工作正常。



我不知道这是否符合你的任务指南。你

通常会跟踪链表中的头部。如果你追踪尾巴并链接回头部,那么你真的只是在转换

术语,因为从概念上讲你的列表仍然是从头到尾。




Noah Roberts写道:


2005写道:
< blockquote class =post_quotes>



在C ++中,以下是否考虑过最佳实践?

- 将aguments传递给函数(即函数不带任何参数




嗯?将参数传递给不带

参数的函数是一种好习惯吗?那是你在问什么?不它不是。它甚至不会编译b
。通常,当函数

需要输入或参数时,会将参数传递给函数。


- 使用return语句返回值



你还会如何返回值?



还有别的吗?



你的帖子没有多大意义。也许你需要更清楚地想一想你要问的是什么。



这个问题的原因是我有我要求修改的赋值是要求修改,以便main将从main

本身调用所有函数,并且除第一个函数外不传递任何参数。



好​​的。



另一个问题是LinkedList。我不应该通过Head

指针或添加一个全局变量。该类只有* m_pLink(

尾指针)。是否可以将头指针分配给m_pLink

(m_pLink确实获取当前指针值,因为它在

链上进行,但是分配了当前最高指针值)?我这样做了

代码工作正常。



我不知道这是否符合你的任务指南。你

通常会跟踪链表中的头部。如果你追踪尾巴并链接到头部,那么你真的只是在转换

术语,因为从概念上讲你的列表仍然是从头到尾。






在C ++中,以下是否考虑过最佳实践?

- 将aguments传递给函数(即设计函数,以便它们更好地接受参数)

- 使用return语句返回值


还有什么吗?


这个问题的原因是我有一个作业,我要求修改
,以便主要调用所有的功能来自main

本身并且除了第一个函数之外也不传递任何参数。


另一个问题是LinkedList。我不应该通过Head

指针或添加一个全局变量。该类只有* m_pLink(

尾指针)。是否可以将头指针分配给m_pLink

(m_pLink确实获取当前指针值,因为它在

链上进行,但是分配了当前最高指针值)?我这样做了,

代码工作正常。


我不认为如果你知道尾巴你可以得到头?


谢谢


2005写道:


Noah Roberts写道:


> 2005写道:


>>嗨

在C ++中,以下是否考虑过最佳实践?
- 将aguments传递给函数(即函数不带任何参数


嗯?将参数传递给不带参数的函数是一种好习惯吗?那是你在问什么?不它不是。它甚至不会编译。通常,当函数需要输入或参数时,将参数传递给函数。


>> - 使用return语句返回值


你还会怎样返回值?


>>>
还有别的吗?


你的帖子没有多大意义。也许你需要更清楚地思考你的问题。


>>>
这个问题的原因是我有一个任务,我要求修改,以便main将从main
本身调用所有函数,并且除了第一个函数之外也不传递任何参数。


好的。


>>>
另一个问题是LinkedList。我不应该传递Head
指针或添加全局变量。该类只有* m_pLink(
尾指针)。是否可以将头指针分配给m_pLink
(m_pLink确实获取当前指针值,因为它在
链上进行,但是分配了当前最高指针值)?我这样做了,
代码工作正常。


我不知道这是否符合你的任务指南。你通常会在链表中跟踪头部。如果您跟踪尾部并链接回头部,那么您实际上只是颠倒了术语,因为从概念上讲,您的列表仍然是从头到尾。



[SNIP-repeated-post]


当您被要求澄清时,请这样做。重新发布您的原始文件

逐字对您或您想要帮助的人没有帮助。


-

WW aka Attila

:::

Spock先生有多少只耳朵?三,左耳,右耳和最后一个前耳。


Hi

In C++, are the following considered best practices or not?
- passing aguments to functions (ie functions do not take any arguments
)
- returning values using return statement

Anything else?

The reason for this question is that I had an assignment in which I was
asked to modify so that the main will call all the functions from main
itself and also do not pass any arguments except the first function.

Another issue was a LinkedList. I was not supposed to pass the Head
pointer or add a global variable. The class only had *m_pLink (the
tail pointer). Would it be ok to assign the head pointer to m_pLink
(m_pLink does take current pointer values as it progress throuhgh the
chain, but assigned the top current pointer value)? I did that and the
code works fine.

Thank you

解决方案


2005 wrote:

Hi

In C++, are the following considered best practices or not?
- passing aguments to functions (ie functions do not take any arguments
)

Huh? Is it good practice to pass arguments to functions that take no
arguments? Is that what you are asking? No, it is not. It won''t even
compile. Normally one passes arguments to functions when the functions
need input, or arguments.

- returning values using return statement

How else would you return values?

>
Anything else?

Your post isn''t making a lot of sense. Maybe you need to think more
clearly about what you are asking.

>
The reason for this question is that I had an assignment in which I was
asked to modify so that the main will call all the functions from main
itself and also do not pass any arguments except the first function.

Ok.

>
Another issue was a LinkedList. I was not supposed to pass the Head
pointer or add a global variable. The class only had *m_pLink (the
tail pointer). Would it be ok to assign the head pointer to m_pLink
(m_pLink does take current pointer values as it progress throuhgh the
chain, but assigned the top current pointer value)? I did that and the
code works fine.

I have no idea if that follows the guidelines to your assignment. You
would normally keep track of the head in a linked list. If you track
the tail and link back to the head then really you are just reversing
terminology as conceptually your list is still from head to tail.



Noah Roberts wrote:

2005 wrote:

Hi

In C++, are the following considered best practices or not?
- passing aguments to functions (ie functions do not take any arguments
)


Huh? Is it good practice to pass arguments to functions that take no
arguments? Is that what you are asking? No, it is not. It won''t even
compile. Normally one passes arguments to functions when the functions
need input, or arguments.

- returning values using return statement


How else would you return values?


Anything else?


Your post isn''t making a lot of sense. Maybe you need to think more
clearly about what you are asking.


The reason for this question is that I had an assignment in which I was
asked to modify so that the main will call all the functions from main
itself and also do not pass any arguments except the first function.


Ok.


Another issue was a LinkedList. I was not supposed to pass the Head
pointer or add a global variable. The class only had *m_pLink (the
tail pointer). Would it be ok to assign the head pointer to m_pLink
(m_pLink does take current pointer values as it progress throuhgh the
chain, but assigned the top current pointer value)? I did that and the
code works fine.


I have no idea if that follows the guidelines to your assignment. You
would normally keep track of the head in a linked list. If you track
the tail and link back to the head then really you are just reversing
terminology as conceptually your list is still from head to tail.

Hi

In C++, are the following considered best practices or not?
- passing aguments to functions (ie design functions so that they
better take no arguments)
- returning values using return statement

Anything else?

The reason for this question is that I had an assignment in which I was
asked to modify so that the main will call all the functions from main
itself and also do not pass any arguments except the first function.

Another issue was a LinkedList. I was not supposed to pass the Head
pointer or add a global variable. The class only had *m_pLink (the
tail pointer). Would it be ok to assign the head pointer to m_pLink
(m_pLink does take current pointer values as it progress throuhgh the
chain, but assigned the top current pointer value)? I did that and the
code works fine.

I do Not think that you can get Head if you know the tail?

Thank you


2005 wrote:

Noah Roberts wrote:

>2005 wrote:

>>Hi

In C++, are the following considered best practices or not?
- passing aguments to functions (ie functions do not take any arguments
)


Huh? Is it good practice to pass arguments to functions that take no
arguments? Is that what you are asking? No, it is not. It won''t even
compile. Normally one passes arguments to functions when the functions
need input, or arguments.

>>- returning values using return statement


How else would you return values?

>>>
Anything else?


Your post isn''t making a lot of sense. Maybe you need to think more
clearly about what you are asking.

>>>
The reason for this question is that I had an assignment in which I was
asked to modify so that the main will call all the functions from main
itself and also do not pass any arguments except the first function.


Ok.

>>>
Another issue was a LinkedList. I was not supposed to pass the Head
pointer or add a global variable. The class only had *m_pLink (the
tail pointer). Would it be ok to assign the head pointer to m_pLink
(m_pLink does take current pointer values as it progress throuhgh the
chain, but assigned the top current pointer value)? I did that and the
code works fine.


I have no idea if that follows the guidelines to your assignment. You
would normally keep track of the head in a linked list. If you track
the tail and link back to the head then really you are just reversing
terminology as conceptually your list is still from head to tail.

[SNIP-repeated-post]

When you are asked to clarify please do so. Reposting your original text
verbatim does not help either you, or the people who would like to help.

--
WW aka Attila
:::
How many ears does Mr. Spock have? Three, a left ear, a right ear, and a
final front ear.


这篇关于C ++最佳实践,OOD,链表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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