| |

VerySource

 Forgot password?
 Register
Search
View: 712|Reply: 3

How to implement one button for calculation and another button for save?

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-20 15:30:01
| Show all posts |Read mode
I want to design two buttons, one for calculation and one for save
I want to achieve this:
Define a class,
Two class member functions in the class define a pointer. Because the memory size pointed to by the pointer is not fixed, the application for memory must be placed in one of the member functions, but the operation result must be saved in the other function.
Is the process of implementing operations in one member function and saving the results with another member function
How to achieve?

E.g
class a
{
public:
float * f;
a :: fun1 ();
a :: fun2 ();
};

a :: fun1 ()
{
f = new float [10];
...
Operation
...
}

a :: fun2 ()
{
CFile file;
file.open (filename, CFile :: modeCreate | modeWrite);
file.write (f, 10 * 4);
}
Reply

Use magic Report

0

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Korea, Republic of

Post time: 2020-7-5 14:15:01
| Show all posts
This is a problem caused by incorrect design ideas
Whether your code is correct or not
"Because the size of the memory pointed to by the pointer is not fixed" To solve this problem, you need to use vector instead of continuing to use array to solve.
This thing must be put in the big picture
private:vector<float> vecData;

Use stl as soon as possible to get rid of array troubles~~~
Reply

Use magic Report

0

Threads

36

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-7-10 22:15:01
| Show all posts
It looks like you are in a multi-threaded program, but also pay attention to use mutex locks to protect data
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-7-29 12:00:01
| Show all posts
Thanks for reminding
Used vector before
Long time, forget
Now solved
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list